python webscraper stack overflow

Solutions on MaxInterview for python webscraper stack overflow by the best coders in the world

showing results for - "python webscraper stack overflow"
Diane
09 Jun 2018
1import urllib2
2from BeautifulSoup import BeautifulSoup
3# or if you're using BeautifulSoup4:
4# from bs4 import BeautifulSoup
5
6soup = BeautifulSoup(urllib2.urlopen('http://example.com').read())
7
8for row in soup('table', {'class': 'spad'})[0].tbody('tr'):
9    tds = row('td')
10    print tds[0].string, tds[1].string
11    # will print date and sunrise