使用wget从谷歌学者搜索结果下载所有pdf文件

时间:2012-09-04 23:03:02

标签: unix wget web-crawler

我想写一个简单的网络蜘蛛,或者只是使用wget从谷歌学者那里下载pdf结果。这对于获得研究论文来说实际上是一种非常漂亮的方式。

我已经在stackoverflow上阅读了以下页面:

Crawl website using wget and limit total number of crawled links

How do web spiders differ from Wget's spider?

Downloading all PDF files from a website

How to download all files (but not HTML) from a website using wget?

最后一页可能是最具启发性的。我确实按照this的建议尝试使用wget

我的Google学者搜索结果页面为thus,但未下载任何内容。

鉴于我对webspiders的理解程度很低,我该怎么办呢?我确实认识到写蜘蛛可能非常复杂,这是我可能不想进行的项目。如果可以使用wget,那将是非常棒的。

1 个答案:

答案 0 :(得分:11)

wget -e robots=off -H --user-agent="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008092416 Firefox/3.0.3" -r -l 1 -nd -A pdf http://scholar.google.com/scholar?q=filetype%3Apdf+liquid+films&btnG=&hl=en&as_sdt=0%2C23

有几点需要注意:

  1. 在搜索查询中使用filetyle:pdf
  2. 一级递归
  3. - 仅接受pdfs的pdf
  4. -H跨越主机
  5. -e robots = off并使用--user-agent将确保获得最佳结果。 Google学术搜索拒绝空白用户代理,而pdf存储库可能会禁止机器人。
  6. 当然,限制只会是第一页的结果。你可以扩展递归的深度,但这将是疯狂的并且永远。我建议使用Beautiful Soup和wget子进程之类的组合,以便您可以战略性地解析和遍历搜索结果。

相关问题