如何使用beautiful soup浏览结果的所有页面。例如,我必须从这个网站上删除:
http://www.ncbi.nlm.nih.gov/pubmed
搜索查询是
“((肿瘤学)和乳腺癌”,结果是“
,没有引号。
我怎么把所有的书页拿来?我尝试在请求头中查找表单数据。尝试修改一些字段。我可以修改它,每一页有200个条目。但不会再有了。实际上,我需要遍历页面来获取所有内容。
任何帮助都将不胜感激。在
假设现在,我只想看看第四页。在
规范相关部分:
post_params = {
'term' : val,
'EntrezSystem2.PEntrez.PubMed.Pubmed_ResultsPanel.Pubmed_DisplayBar.PageSize' : 20,
'EntrezSystem2.PEntrez.PubMed.Pubmed_ResultsPanel.Pubmed_DisplayBar.sPageSize' : 20,
'coll_start' : 61,
'citman_count' : 20,
'citman_start' : 61,
'coll_start2' : 61,
'citman_count2' : 20,
'citman_start2' : 61,
'CollectionStartIndex': 1,
'CitationManagerStartIndex' : 1,
'CitationManagerCustomRange' : 'false',
'EntrezSystem2.PEntrez.PubMed.Pubmed_ResultsPanel.Entrez_Pager.cPage' : 3,
'EntrezSystem2.PEntrez.PubMed.Pubmed_ResultsPanel.Entrez_Pager.CurrPage' : 4,
}
"""This part handles the scraping business"""
post_args = urllib.urlencode(post_params)
baseurl = 'http://www.ncbi.nlm.nih.gov'
url = 'http://www.ncbi.nlm.nih.gov/pubmed/'
page = urllib2.urlopen(url, post_args)
page = page.read()
soup = BeautifulSoup(page)
soup.prettify()
它仍然获取第一页。一旦这一部分成功,我就在考虑迭代这个代码,每次修改参数。在
永远不要抓取PubMed总是有一个更简单的方法直接检索数据。安装并使用BioPython包。下面是一个简单的脚本,可以使用您的查询获取前10篇论文:
该手册内容广泛,但您只需阅读有关使用biopythonentrez搜索和获取记录以及使用biopythonmedline解析结果的部分。在
相关问题 更多 >
编程相关推荐