Python Forum
Thread Rating:
  • 3 Vote(s) - 3.33 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Web Scrapping
#1
I am in the process of creating a web scrapping tool from scratch that I will use at my job. I work at a medical transportation company and will be scraping a website for trip information and saving it to a database. I am new to programming and felt for a "real project" it would be something interesting to tackle. I have been studying python for about 3 weeks. 2 hours a day to give you a background on my knowledge.



session.post('https://www.medanswering.com/login.taf?_function=check', params=payload)
r = session.get('https://www.medanswering.com/admintrips.taf?_function=detail&Trip_Auth_ID=' + invoice)
html_content = r.content
html_content2 = r.text
soup = BeautifulSoup(html_content, 'html.parser')
soup2 = BeautifulSoup(html_content2, 'html.parser')


#Grabbing the Date and time
PU_time_finder = soup2.find_all("td")[100]
print(PU_time_finder.text)


Whats happening is I obtain the data I need. However, I am retrieving it from a table on a website and the date and time I need are in the same "td" tag. Causing the output below

10/24/17
9:30 am



It appears in my console exactly like that. I thought "hmm maybe I can put it in a list" So i tried and it didnt work. I am sure there is more code needed to manipulate it a little more. I am using the libraries "requests" and "BeautifulSoup4".

P.S I did not incorporate the authentication part of my code showing the Username and password. That part is functioning correctly.
Reply
#2
please, rather than posting your code in bold, use code tags see BBCODE
when pasting code, use shift-ctrl-v to preserve indentation
Reply
#3
Quote:and the date and time I need are in the same "td" tag.
Whats the exact html of the td code for that section?
Recommended Tutorials:
Reply
#4
I actually thought of a solution and was able to implement it. What I did was convert it to a list and removed the characters that way and converted it back to a string. Very excited it worked!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem with scrapping Website giddyhead 1 1,629 Mar-08-2024, 08:20 AM
Last Post: AhanaSharma
  python web scrapping mg24 1 329 Mar-01-2024, 09:48 PM
Last Post: snippsat
  How can I ignore empty fields when scrapping never5000 0 1,393 Feb-11-2022, 09:19 AM
Last Post: never5000
  Suggestion request for scrapping html table Vkkindia 3 2,033 Dec-06-2021, 06:09 PM
Last Post: Larz60+
  web scrapping through Python Naheed 2 2,621 May-17-2021, 12:02 PM
Last Post: Naheed
  Website scrapping and download santoshrane 3 4,322 Apr-14-2021, 07:22 AM
Last Post: kashcode
  Newbie help with lxml scrapping chelsealoa 1 1,864 Jan-08-2021, 09:14 AM
Last Post: Larz60+
  Scrapping Sport score laplacea 1 2,259 Dec-13-2020, 04:09 PM
Last Post: Larz60+
  How to export to csv the output of every iteration when scrapping with a loop efthymios 2 2,290 Nov-30-2020, 07:46 PM
Last Post: efthymios
  Web scrapping - Stopped working peterjv26 2 3,082 Sep-23-2020, 08:30 AM
Last Post: peterjv26

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020