Python实现115网盘自动下载的方法
作者:shichen2014 时间:2022-08-13 21:57:33
本文实例讲述了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,下载
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
BootStrap创建响应式导航条实例代码
2023-08-09 02:09:55
![](https://img.aspxhome.com/file/2023/4/56054_0s.gif)
python实现计数排序与桶排序实例代码
2023-12-28 11:32:37
![](https://img.aspxhome.com/file/2023/9/82899_0s.png)
Python3.5字符串常用操作实例详解
2023-08-31 00:25:53
![](https://img.aspxhome.com/file/2023/8/62608_0s.png)
MySQL与PHP的基础与应用专题之创建数据库表
2023-11-21 04:12:28
![](https://img.aspxhome.com/file/2023/2/110342_0s.png)
python用fsolve、leastsq对非线性方程组求解
2021-06-28 23:33:29
asp如何设定程序的执行次数?
2010-05-18 18:31:00
用数据库生成不重复的流水号
2007-10-06 22:49:00
python设计模式之抽象工厂模式详解
2023-06-11 22:15:51
![](https://img.aspxhome.com/file/2023/7/76127_0s.jpg)
php5.4传引用时报错问题分析
2023-11-14 15:03:17
详解基于pycharm的requests库使用教程
2023-08-12 09:40:39
![](https://img.aspxhome.com/file/2023/0/64740_0s.jpg)
django自带的server 让外网主机访问方法
2023-06-03 22:59:50
python中偏函数partial用法实例分析
2021-03-24 21:35:23
python实现的config文件读写功能示例
2021-10-11 07:28:04
HTML邮件的又一点思考
2009-05-06 13:33:00
![](https://img.aspxhome.com/file/UploadPic/20095/6/mail-59s.png)
Python如何定义有默认参数的函数
2023-08-05 14:38:30
彻底弄懂CSS盒子模式之五(定位强化练习)
2007-05-11 16:51:00
![](https://img.aspxhome.com/file/uploadpic/20075/2007511165148243.gif)
Python3将jpg转为pdf文件的方法示例
2021-06-25 11:31:17
PyTorch学习笔记之回归实战
2023-09-17 10:26:19
![](https://img.aspxhome.com/file/2023/2/78752_0s.png)
有用的:nth-child秘方
2011-07-01 12:56:11
Web 设计:实现干净代码的12条定律
2008-12-04 13:27:00
![](https://img.aspxhome.com/file/UploadPic/200812/4/22008111521256-30.gif)