我爱帮助网-手册QQ交流群

Nas交流与矿渣群(unraid 群晖 猫盘 蜗牛等):580680114         物联网/智能家居群:518812757             帮助教程:手册大全

软件使用与建站群:1057308983      虚拟化交流群:13448651

0

Python爬取百度云网盘的资源

[Python]代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
importurllib
importurllib.request
importwebbrowser 
importre
defyunpan_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')
    foriinm:
        f.write(i)
        f.write('\n\n')
    f.close();
    print("抓取成功!")
     
     
 
if__name__=='__main__':
    print('爬取百度云盘资源快捷爬取')
    key=input('输入你想搜索的资源:')
    yunpan_search(key)