Web scraping with Python -


i'd grab daily sunrise/sunset times web site. possible scrape web content python? modules used? there tutorial available?

use urllib2 in combination brilliant beautifulsoup library:

import urllib2 beautifulsoup import beautifulsoup # or if you're using beautifulsoup4: # bs4 import beautifulsoup  soup = beautifulsoup(urllib2.urlopen('http://example.com').read())  row in soup('table', {'class': 'spad'})[0].tbody('tr'):     tds = row('td')     print tds[0].string, tds[1].string     # print date , sunrise 

Comments

Popular posts from this blog

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

c++ - Convert big endian to little endian when reading from a binary file -