Python实现115网盘自动下载的方法

 更新时间:2014年09月30日 14:45:06   投稿:shichen2014  
这篇文章主要介绍了Python实现115网盘自动下载的方法,可实现自动调用115客户端进行下载的功能,非常实用,需要的朋友可以参考下

本文实例讲述了Python实现115网盘自动下载的方法。分享给大家供大家参考。具体实现方法如下:

实例中的1.txt,是网页http://bbs.pediy.com/showthread.php?t=144788另存为1.txt

通过每3秒钟复制一个下载链接到粘贴板,复制时会自动调用115客户端下载,每下载10个文件会手工输入一个字符,防止一下下载太多,卡死机器

具体代码如下:

import re, os, time
import webbrowser
import urllib
  
if __name__ == "__main__":
  fp = open("c:\\1.txt")
  
  https = re.compile(r"(http://u.*)")
  urlList = []
  for url in https.findall(fp.read()):
    urlList.append(url)
  
  downloadUrlList = []
  IsFirst = 1
  print urlList
  for url in urlList:
    doc = urllib.urlopen(url).read()
    reDownloadUrl = re.compile(r'(http://115.com/file/.*)"')
    for downloadUrl in reDownloadUrl.findall(doc):
      if IsFirst:
        downloadUrlList.append(downloadUrl)
        IsFirst = 0
    IsFirst = 1
    #print "-"*20
  
  for url in downloadUrlList:
    print url
    
  import win32clipboard
  import win32con
  def copyToClipboard(copyText):
    win32clipboard.OpenClipboard()
    win32clipboard.EmptyClipboard()
    win32clipboard.SetClipboardData(win32con.CF_TEXT, copyText)
    win32clipboard.CloseClipboard()
    
  #downloadUrlList = ["http://115.com/file/cmlirmfo","http://115.com/file/ew7htcjc","http://115.com/file/cm25l95e","http://115.com/file/atn8dsgj","http://115.com/file/b3e0ae5k","http://115.com/file/cm27rs3g","http://115.com/file/cmkwjpa1","http://115.com/file/ew4sx25c","http://115.com/file/d2b1alj8","http://115.com/file/b3c29o48","http://115.com/file/ew8ctkyc","http://115.com/file/b3m4ea70","http://115.com/file/atcph3md","http://115.com/file/ew9fw53a","http://115.com/file/cm512ct1","http://115.com/file/ewx7d35c","http://115.com/file/at8nd5xj","http://115.com/file/ewcs6jbj","http://115.com/file/b3104ve1","http://115.com/file/b3b1koke","http://115.com/file/d2st6pv6","http://115.com/file/atb20b6h","http://115.com/file/b353salz","http://115.com/file/atzilrkp","http://115.com/file/cmg35and","http://115.com/file/cmq5ceje","http://115.com/file/atkdb5oc","http://115.com/file/d297u2v6","http://115.com/file/ataqteic","http://115.com/file/cm7ralmz","http://115.com/file/cm70v4nr","http://115.com/file/cmfhr2so","http://115.com/file/atvtkaja","http://115.com/file/b3t7b6aw","http://115.com/file/atoyp4iz","http://115.com/file/ewpk79kj","http://115.com/file/at5k044x","http://115.com/file/d2mo0678","http://115.com/file/a9hegswp","http://115.com/file/bl472ir1","http://115.com/file/dl2dgqi9","http://115.com/file/dl20ky2a","http://115.com/file/bll2yssk","http://115.com/file/a9jzzlca","http://115.com/file/c4z1ek4d","http://115.com/file/blpk4pv1","http://115.com/file/c4rjotdz","http://115.com/file/a9g43daa","http://115.com/file/efnn38jr","http://115.com/file/c4leomjd","http://115.com/file/dlpw9s6i","http://115.com/file/a9n0jv8x","http://115.com/file/c48savoo","http://115.com/file/ef8og8la","http://115.com/file/a9cjk9lx","http://115.com/file/blo38e31","http://115.com/file/a987cika","http://115.com/file/c4vic87g","http://115.com/file/bl5l0syx","http://115.com/file/c4gdl7ne","http://115.com/file/efym0xhy","http://115.com/file/dl88b43f","http://115.com/file/bw4wfxa1","http://115.com/file/eswz3bgj","http://115.com/file/czw0b3g2","http://115.com/file/dis9mjcx","http://115.com/file/ajzrgiyz","http://115.com/file/es5o43lz","http://115.com/file/dnasw0kp","http://115.com/file/dnagnndx","http://115.com/file/clwr2xxg","http://115.com/file/bhbcnnwe","http://115.com/file/aq2rp9ga","http://115.com/file/e601turs","http://115.com/file/dn46qs7x","http://115.com/file/clwonrwg","http://115.com/file/dn43i7jf","http://115.com/file/bhbgrnfz","http://115.com/file/dnsl0kxp"]
  i = 0
  while i<100:
    if len(downloadUrlList) == 0:
      break
    copyToClipboard(downloadUrlList.pop())
    time.sleep(3)
    i = i + 1
    if i % 10 == 0:
      os.system("pause")
  
  print "after pause"

希望本文所述对大家的Python程序设计有所帮助.

相关文章

  • 利用python和ffmpeg 批量将其他图片转换为.yuv格式的方法

    利用python和ffmpeg 批量将其他图片转换为.yuv格式的方法

    今天小编就为大家分享一篇利用python和ffmpeg 批量将其他图片转换为.yuv格式的方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2019-01-01
  • Pandas把dataframe或series转换成list的方法

    Pandas把dataframe或series转换成list的方法

    这篇文章主要介绍了Pandas把dataframe或series转换成list的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-06-06
  • python 三种方法提取pdf中的图片

    python 三种方法提取pdf中的图片

    这篇文章主要介绍了python 三种方法提取pdf中的图片,帮助大家更好的理解和使用python,感兴趣的朋友可以了解下
    2021-02-02
  • python中实现将多个print输出合成一个数组

    python中实现将多个print输出合成一个数组

    下面小编就为大家分享一篇python中实现将多个print输出合成一个数组,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2018-04-04
  • Python实现好友全头像的拼接实例(推荐)

    Python实现好友全头像的拼接实例(推荐)

    下面小编就为大家带来一篇Python实现好友全头像的拼接实例(推荐)。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2017-06-06
  • python程序文件扩展名知识点详解

    python程序文件扩展名知识点详解

    在本篇文章里小编给大家整理的是关于python程序文件扩展名知识点详解内容,需要的朋友们学习参考下。
    2020-02-02
  • PyCharm中Matplotlib绘图不能显示UI效果的问题解决

    PyCharm中Matplotlib绘图不能显示UI效果的问题解决

    这篇文章主要介绍了PyCharm中Matplotlib绘图不能显示UI效果的问题解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-03-03
  • python批量修改文件名的实现代码

    python批量修改文件名的实现代码

    这篇文章主要介绍了python批量修改文件名的实现代码,需要的朋友可以参考下
    2014-09-09
  • Python聊天室实例程序分享

    Python聊天室实例程序分享

    这篇文章主要为大家分享了Python Socket编程之聊天室示例程序代码,感兴趣的小伙伴们可以参考一下
    2016-01-01
  • python字符串拼接+和join的区别详解

    python字符串拼接+和join的区别详解

    这篇文章主要给大家介绍了关于python字符串拼接+和join的区别的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-12-12

最新评论