Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
scapping an html document
#3
hi,
The code is working now.
I did the following changes
with open('Basic Materials.htm') as fp:
    soup=BeautifulSoup(fp,'lxml')
    table=soup.find('div',{'class':'sfe-break-bottom'})
    for row in table.find_all('tr'):
         for cells in row.find_all('td'):
                for link in cells.find_all('a', limit=3):
                    print(link.get_text()) # gets the name 
                    print(link.get('href')) # gets the links
now its working.I removed the cells variable and used nested if statements
Reply


Messages In This Thread
scapping an html document - by jonelya - Aug-13-2017, 08:00 PM
RE: scapping an html document - by nilamo - Aug-14-2017, 05:34 PM
RE: scapping an html document - by jonelya - Aug-15-2017, 07:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Lightbulb Python Obstacles | Kung-Fu | Full File HTML Document Scrape and Store it in MariaDB BrandonKastning 5 2,973 Dec-29-2021, 02:26 AM
Last Post: BrandonKastning
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,722 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 2,405 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning

Forum Jump:

User Panel Messages

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