活跃农民
- 积分
- 379
- 大米
- 颗
- 鳄梨
- 个
- 水井
- 尺
- 蓝莓
- 颗
- 萝卜
- 根
- 小米
- 粒
- 学分
- 个
- 注册时间
- 2009-7-9
- 最后登录
- 1970-1-1
|
你好lz,我用了你的方法,但是为什么这个pdf文件没法抓下来呢?我用web browser都能打开和下载
谢谢你:)- import urllib2. Χ
- def main():
- download_file("https://dl.sciencesocieties.org/publications/aj/pdfs/107/5/1701?search-result=1", "test")
- def download_file(download_url, filename):.google и
- .google и
- header = {'Host': 'dl.sciencesocieties.org',
- 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0',
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
- 'Accept-Encoding': 'gzip, deflate',
- 'Connection': 'keep-alive'}
- req = urllib2.Request(download_url, headers = header) #request.--
- con = urllib2.urlopen( req ) #content
- file = open(filename +".pdf", 'w')
- file.write(con.read())
- file.close(). check 1point3acres for more.
- print("Completed")
- if __name__ == "__main__":. From 1point 3acres bbs
- main()
复制代码 |
|