本帖最后由 ivor 于 2017-11-24 21:40 编辑
回复 1# wzf1024
Python3.5
下载地址保存为list.txt,复制到迅雷批量下载- # coding:utf-8
- import bs4
- import urllib.request as url
-
-
- web_site = 'http://pmmp.cnki.net/OperatingDiscipline/Details.aspx?id=%s'
- with open('list.txt','w') as wfile:
- for num in range(10001,16715):
- try:
- req = url.urlopen(web_site % str(num)[1:])
- soup = bs4.BeautifulSoup(req,'html.parser')
- for i in soup.find_all('a'):
- if i.string == '全文下载':
- downloadUrl = url.unquote(i.get('href'))
- print(downloadUrl, file=wfile, flush=True)
- print(downloadUrl)
- break
- except:
- print("服务器错误!请检查网址连接 当前id=%s" % str(num)[1:])
- pass
- input("回车结束")
复制代码
|