首页 > 编程知识 正文

python 爬虫 百度网盘,python爬虫百度网盘文件

时间:2023-05-03 09:33:00 阅读:257067 作者:4424

单纯的唇彩,初学python.

1.[代码][Python]代zjdls/p>

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 和谐的犀牛/p>

})

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)

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。