这是在
BeautifulSoup中使用
SoupStrainer类的一小段代码:
import httplib2from BeautifulSoup import BeautifulSoup, SoupStrainerhttp = httplib2.Http()status, response = http.request('http://www.nytimes.com')for link in BeautifulSoup(response, parse_only=SoupStrainer('a')): if link.has_attr('href'): print(link['href'])


