【问题标题】:How to automatically retrieve pdf documents of a specific subject from web? [closed]如何从网络自动检索特定主题的 pdf 文档? [关闭]
【发布时间】:2014-07-19 18:58:21
【问题描述】:

我必须从网上下载大量关于特定主题的 pdf 文档。

有什么工具可以帮我完成这个任务

【问题讨论】:

  • 你有文件的网址吗?
  • @nofinator.. 我没有网址。我只知道应该从哪个区域下载文件。例如:操作系统、网络等

标签: python pdf web


【解决方案1】:

只要您有一个 URL 列表,就有很多可能性,例如wget、curl、python 等与python标准库:

import urllib2
url_list = ['http://www.blah.com/1.pdf', 'http://www.blah.com/2.pdf'.....]
for url in list_of_urls:
    outfile = os.path.basename(url)
    with open(outfile, 'w') as out:
        print "Downloading %s to %s" % (url, outfile)
        out.write(urllib2.open(url).read())

或者您可以查看requests 库。

编辑 您添加了一条没有预定义 URL 列表的评论。您需要查询某些内容以获取候选人列表,然后使用建议的方法之一下载它们,例如使用Google custom search api 提交搜索,然后分析JSON 格式的结果,构造一个要下载的URL 列表。

如果你需要解析HTML,那就看看Beautiful Soup

【讨论】:

    猜你喜欢
    • 2013-07-18
    • 2013-10-22
    • 2011-04-11
    • 2012-12-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    相关资源
    最近更新 更多