import urllib2from BeautifulSoup import BeautifulSouppage = urllib2.urlopen('http://yahoo.com').read()soup = BeautifulSoup(page)soup.prettify()for anchor in soup.findAll('a', href=True): print anchor['href']它会给你URL列表。现在,您可以遍历这些URL并解析数据。
inner_div = soup.findAll("div", {"id": "y-shade"})这是一个例子。您可以阅读BeautifulSoup教程。



