zoukankan      html  css  js  c++  java
  • python爬虫:爬取百度云盘资料,保存下载地址、链接标题、链接详情

    在网上看到的教程,但是我嫌弃那个教程写的乱(虽然最后显示我也没高明多少,哈哈),就随手写了一个

    主要是嫌弃盘搜那些恶心的广告,这样直接下载下来,眼睛清爽多了。

    用pyinstall 打包成EXE文件,就可以安安静静的下载东西了。。。。

     #refer:http://upvup.com/html/python/2015-12-13/21.html

    #!/usr/bin/python
    # -*- encoding:utf-8 -*-

    import requests
    from bs4 import BeautifulSoup
    import sys
    reload(sys)
    sys.setdefaultencoding('utf-8')

    def yunpan_search(key):
    url='http://www.wangpansou.cn/s.php?q='+key
    html=requests.get(url)
    soup=BeautifulSoup(html.text,"lxml")
    url_get=soup.find_all('a',{'class':'cse-search-result_content_item_top_a'})
    info_get=soup.find_all('div',{'class':'cse-search-result_content_item_mid'})
    f = open('baidu_source.txt','w')
    for i in range(len(url_get)):
    href=url_get[i]['href']
    title=''
    for c in url_get[i].children:
    title+=c.string.strip()

    information=''
    for info in info_get[i].children:
    information+=info.string.strip().replace(' ','')

    print str(i+1)+'_'*60
    print '下载地址--'+href+' '+'链接标题--'+title+' '+'链接详情--'+information+' '
    f.write(str(i+1)+'. _____________________________________________________________________ ')
    f.write('下载地址--'+href+' '+'链接标题--'+title+' '+'链接详情--'+information+' ')
    f.close()


    if __name__=='__main__':
    key=raw_input('please input what you want to look for:')
    yunpan_search(key)
    print('finish')
  • 相关阅读:
    Mongodb在Linux下的安装和启动和配置
    Java线程--Exchanger使用
    Java线程--Phaser使用
    Java线程--CyclicBarrier使用
    Java线程--CountDownLatch使用
    Java线程状态介绍
    Java8 Stream 的一些操作和介绍
    Java正则
    Linux curl命令进行网络请求
    Netty入门使用教程
  • 原文地址:https://www.cnblogs.com/miranda-tang/p/5584825.html
Copyright © 2011-2022 走看看