python爬取百度云盘资源
发布时间:2020-05-25 01:34:13 所属栏目:Python 来源:互联网
导读:python爬取百度云盘资源
|
下面是脚本之家 jb51.cc 通过网络收集整理的代码片段。 脚本之家小编现在分享给大家,也给大家做个参考。 import urllib
import urllib.request
import webbrowser
import re
def yunpan_search(key):
keyword = key
keyword = keyword.encode('utf-8')
keyword = urllib.request.quote(keyword)
url = "http://www.wangpansou.cn/s.php?q="+keyword+"&wp=0&start=0"
#webbrowser.open(url)
req = urllib.request.Request(url,headers = {
'Connection': 'Keep-Alive','Accept': 'text/html,application/xhtml+xml,*/*','Accept-Language': 'en-US,en;q=0.8,zh-Hans-CN;q=0.5,zh-Hans;q=0.3','User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko'
})
opener = urllib.request.urlopen(req)
html = opener.read()
html = html.decode('utf-8')
rex = r'https?://pan.baidu.com.*?uk=[0-9]{10}.*[d+?]"'
m = re.findall(rex,html)
f = open('/root/Desktop/txt.txt','w')
for i in m:
f.write(i)
f.write('nn')
f.close();
print("抓取成功!")
if __name__=='__main__':
print('爬取百度云盘资源快捷爬取')
key = input('输入你想搜索的资源:')
yunpan_search(key)
以上是脚本之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。 如果觉得脚本之家网站内容还不错,欢迎将脚本之家网站推荐给程序员好友。 (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
