结合使用urllib2和出色的BeautifulSoup库:
import urllib2from BeautifulSoup import BeautifulSoup# or if you're using BeautifulSoup4:# from bs4 import BeautifulSoupsoup = BeautifulSoup(urllib2.urlopen('http://example.com').read())for row in soup('table', {'class': 'spad'})[0].tbody('tr'): tds = row('td') print tds[0].string, tds[1].string # will print date and sunrise
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)