| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
 本帖最后由 小小大鱼 于 2016-3-21 23:17 编辑 ps:其中部分代码来自网络 ,至于是谁的我自己也不清楚了...... 
 
第一次发分享贴,也来个隐藏 ^_^ 
 
废话不多说,直接上代码(目前功能相当简陋,需要的可以自己修改了,欢迎交流)  本脚本已经更新2.0版本:传送门:http://bbs.fishc.com/thread-70206-1-1.html 
 
- #coding = utf-8
 
 - import urllib,urllib.request
 
 - import webbrowser
 
 - import re
 
  
 
- def yunpanSearch(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"
 
  
-     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().decode('utf-8')
 
 -     p=re.compile(r'https?://pan.baidu.com.*\?uk=[0-9]{10}.*[\d+?]"')
 
 -     source=p.findall(html)
 
  
 
-     if source!='':
 
 -         print('\n 爬取成功,链接如下:! \n')
 
 -         for i in source:
 
 -             print(i)
 
 -     else:
 
 -         print('\n 爬虫迷路了!')
 
  
 
- if __name__ == '__main__':
 
 -     print('爬取百度云盘资源快捷爬取')
 
 -     key = input('输入你想搜索的资源:\n')
 
 -     yunpanSearch(key)
 
 
  复制代码 |   
 
 
 
 |