黑松山资源网 Design By www.paidiu.com
其实不是真的创建了批量任务,而是用python创建一个文本文件,每行一个要下载的链接,然后打开迅雷,复制文本文件的内容,迅雷监测到剪切板变化,弹出下载全部链接的对话框~~
实际情况是这样的,因为用python分析网页非常,比如下载某页中的全部pdf链接
from __future__ import unicode_literals from bs import BeautifulSoup import requests import codecs r = requests.get('you url') s = BeautifulSoup(r.text) links = s.findall('a') pdfs = [] for link in links: href = link.get('href') if href.endswith('.pdf'): pdfs.append(href) with open('you file', 'w', 'gb') as f: for pdf in pdfs: f.write(pdf + '\r\n')
使用python创建多个文件
#coding=utf-8 ''' Created on 2012-5-29 @author: xiaochou ''' import os import time def nsfile(s): '''The number of new expected documents''' #判断文件夹是否存在,如果不存在则创建 b = os.path.exists("E:\\testFile\\") if b: print "File Exist!" else: os.mkdir("E:\\testFile\\") #生成文件 for i in range(1,s+1): localTime = time.strftime("%Y%m%d%H%M%S",time.localtime()) #print localtime filename = "E:\\testFile\\"+localTime+".txt" #a:以追加模式打开(必要时可以创建)append;b:表示二进制 f = open(filename,'ab') testnote = '测试文件' f.write(testnote) f.close() #输出第几个文件和对应的文件名称 print "file"+" "+str(i)+":"+str(localTime)+".txt" time.sleep(1) print "ALL Down" time.sleep(1) if __name__ == '__main__': s = input("请输入需要生成的文件数:") nsfile(s)
以上内容是小编给大家分享的Python批量创建迅雷任务及创建多个文件的实例代码,希望对大家有所帮助。
黑松山资源网 Design By www.paidiu.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
黑松山资源网 Design By www.paidiu.com
暂无评论...
更新日志
2024年10月09日
2024年10月09日
- 炉石传说最强术士卡组是哪个 术士最强天梯卡组推荐一览
- 炉石传说最强萨尔卡组是哪个 萨尔最强天梯卡组推荐一览
- 炉石传说最强潜行者卡组是哪个 潜行者最强天梯卡组推荐一览
- 银霞.1983-《爱迷惑我·我住小楼中》台湾复刻版[WAV+CUE]
- [雨果唱片]粤曲名家-《再折长亭柳》[WAV+CUE]
- 刘德华1998-你是我的女人[香港第二版][WAV]
- 压迫感谁最强?外媒评选恐怖游戏最佳女反派
- 还没正式发售:《寂静岭2:重制版》Steam玩家峰值近9000人
- 别搞政确了!超95%国外玩家反对强制包容性
- 《暗喻幻想:ReFantazio》试玩:ATLUS的自我挑战?
- 《憧憬成为魔法少女》第二季 反转魔法少女题材再掀热潮
- 海信AI电视E7N正式发布,引领AI画质新标杆
- 屠洪刚.2002-九九艳阳天【京文】【WAV+CUE】
- 齐秦.1996-丝路【东方】【WAV+CUE】
- 泳儿.2010-VINSELECTION新曲+精选2CD【英皇娱乐】【WAV+CUE】