无法使用漂亮的汤

时间:2016-02-24 05:08:00

标签: python web-scraping beautifulsoup html-parsing

我正在尝试使用以下python查询在纽约时报网站上使用漂亮的汤来搜索ol标签内的搜索结果,即li标签 -

theurl =["http://query.nytimes.com/search/sitesearch/#/Microsoft/"] 
thepage = urllib.request.urlopen(theurl)
soup=BeautifulSoup(thepage, "html.parser")
for profile in soup.findAll("ol",attrs={"class":"searchResultsList flush"}):
   print(profile)

但它只返回以下结果,

<ol class="searchResultsList flush">
</ol>

并且不会返回ol标记内的li list标记。我试过用“lxml”替换“html.parser”并没有帮助。我想它可能是一个安全参数,不让我刮掉搜索结果任何人都可以请确认这个或有解决方案吗?感谢

0 个答案:

没有答案
相关问题