示例#1
0
    def download(self, link, logger):
        '''
        开始下载任务
        '''
        try:
            content = self.fetchContent(link, logger)
            # 继续解析该页面
            soup = bs4.BeautifulSoup(content, "html.parser")
            movieName = soup.title.string
            logger.info('遭遇Boss:' + movieName)
            for tag in soup.find_all(id='Zoom'):
                if (tag.name == 'div'):
                    magnetUrl = self.findMagnetUrl(tag, logger)
                    break
            # 调用迅雷接口方法
            # 1.调用迅雷的代理

    #       thunder = Dispatch('ThunderAgent.Agent64.1') # 64位和32位的区别
            thunder = Dispatch('ThunderAgent.Agent.1')
            thunder.AddTask(magnetUrl, movieName)
            thunder.CommitTasks()
            logger.info("Boss战结束!")
        # 2.系统执行exe的方式打开迅雷并传入下载链接
#                 os.execl("D:\Softwares\Program\Thunder.exe", '-StartType:DesktopIcon', 'magnet:?xt=urn:btih:1710e389ee578b6e1ec2906d6f1e7dceadc1a53a&dn=%e9%98%b3%e5%85%89%e7%94%b5%e5%bd%b1www.ygdy8.com.%e6%9a%97%e6%95%b0%e6%9d%80%e4%ba%ba.BD.720p.%e9%9f%a9%e8%af%ad%e4%b8%ad%e5%ad%97.mkv')
#                 os.execl("D:\Softwares\Program\Thunder.exe", '-StartType:DesktopIcon', 'magnet:?xt=urn:btih:9b9bba10ebce7bfd953e015b25952296a0ec65cc&dn=%e9%98%b3%e5%85%89%e7%94%b5%e5%bd%b1www.ygdy8.com.%e7%8a%ac%e8%88%8d%e7%9c%9f%e4%ba%ba%e7%89%88.BD.720p.%e6%97%a5%e8%af%ad%e4%b8%ad%e5%ad%97.mkv')
        except Exception:
            logger.error(traceback.format_exc())
示例#2
0
def down(url, name, format_):
    thunder = Dispatch('ThunderAgent.Agent64.1')
    # ThunderAgent.Agent.1 低版本可以试试这个
    # AddTask("下载地址", "另存为文件名", "保存目录", "任务注释", "引用地址", "开始模式", "只从原始地址下载", "从原始地址下载线程数")
    # thunder.AddTask('ftp://*****:*****@yg45.dydytt.net:8129/阳光电影www.ygdy8.com.蝙蝠侠:哥谭骑士.BD.720p.中英双字幕.mkv', 'movie.mkv')
    file_name = str(name) + str(format_)
    thunder.AddTask(url, file_name)
    thunder.CommitTasks()
示例#3
0
 def process_item(self, item, spider):
     dict_item = dict(item)
     thunder = Dispatch('ThunderAgent.Agent64.1')
     course_path = "F:\\迅雷下载"
     thunder.AddTask(dict_item["url"], dict_item["fileName"], course_path,
                     "", "", -1, 0, 5)
     thunder.CommitTasks()
     json_str = json.dumps(dict_item, ensure_ascii=False) + "\n"
     self.file.write(json_str)
     return item
示例#4
0
def addTasktoXunlei(down_url):
    flag = False
    o = Dispatch('ThunderAgent.Agent64.1')
    try:
        o.AddTask(down_url, "", "", "", "", -1, 0, 5)
        o.CommitTasks()
        flag = True
    except Exception:
        print(Exception.message)
        print(" AddTask is fail!")
    return flag
示例#5
0
class Thunder():
    def __init__(self, **kwargs):
        self.common = Common()
        self.path = kwargs.get('path') if kwargs.get(
            'path') else self.save_path()

        from win32com.client import Dispatch
        self.thunder = Dispatch('ThunderAgent.Agent64.1')

    def save_path(self):
        parallel = os.path.abspath(os.path.dirname(BASE_DIR))
        flv_path = self.common.mkdir(os.path.join(parallel, 'you_get'))
        return flv_path

    def download1(self, urls):
        for i, url in enumerate(urls):
            self.thunder.AddTask(url, "第{0}集.rmvb".format(i + 1), self.path)
            self.thunder.CommitTasks()

    def download(self, url, name):
        self.thunder.AddTask(url, "第{0}集.rmvb".format(name))
        self.thunder.CommitTasks()
        time.sleep(60)
示例#6
0
class Thunder:
    agent = None

    def __init__(self):
        from win32com.client import Dispatch
        self.agent = Dispatch('ThunderAgent.Agent64.1')

    def download(self, filename, url):
        self.agent.AddTask(url, filename, nStartMode=1)

    def commit(self):
        """
        TODO: 每次提交任务都会弹出新建任务的面板,很烦,
        """
        self.agent.CommitTasks()
def addTasktoXunlei(down_url, course_infos):
    flag = False
    o = Dispatch("ThunderAgent.Agent.1")
    if down_url:
        course_path = os.getcwd()
        try:
            #AddTask("下载地址", "另存文件名", "保存目录","任务注释","引用地址","开始模式", "只从原始地址下载","从原始地址下载线程数")
            o.AddTask(down_url, '', course_path, "", "", -1, 0, 5)
            o.CommitTasks()
            flag = True
        except Exception:

            print(Exception.message)
            print(" AddTask is fail!")
    return flag
示例#8
0
def download(urls, save_path, time_sleep_in_seconds=5):
    """
    download file from given urls and save it to given path
    :param urls: str, urls
    :param save_path: str, full path
    :param time_sleep_in_seconds: int, sleep seconds after call
    :return: None
    """
    path, file = os.path.split(save_path)
    thunder = Dispatch("ThunderAgent.Agent64.1")  # for thunder X
    # thunder = Dispatch("ThunderAgent.Agent.1")  # for other thunder version
    # AddTask("下载地址", "另存文件名", "保存目录","任务注释","引用地址","开始模式", "只从原始地址下载","从原始地址下载线程数")
    thunder.AddTask(urls, file, path, "", "", -1, 0, 5)
    thunder.CommitTasks()
    time.sleep(time_sleep_in_seconds)
示例#9
0
 def addTasktoXunlei(self, down_url):
     flag = False
     from win32com.client import Dispatch
     o = Dispatch("ThunderAgent.Agent.1")
     # http: // cv3.jikexueyuan.com / 201508011650 / a396d5f2b9a19e8438da3ea888e4cc73 / python / course_776 / 01 / video / c776b_01_h264_sd_960_540.mp4
     if down_url:
         course_infos = str(down_url).replace(" ", "").replace("http://", "").split("/")
         course_path = self.get_file_lists(self.course_tag, self.course_id)
         try:
             o.AddTask(down_url, course_infos[len(course_infos) - 1], course_path, "", "http://cv3.jikexueyuan.com",
                       1, 0, 5)
             o.CommitTasks()
             flag = True
         except Exception:
             print(Exception.message)
             print("                     AddTask is fail!")
     return flag
示例#10
0
 def download(self):
     import pythoncom
     pythoncom.CoInitialize()  # 读取word文档的内容,常见错误是,读英文的时候,没有问题,但是碰到中文的时候,就会报错,见下面代码:
     if isinstance(self.proc_exist('Thunder.exe'), int) != None:  # isinstance() 函数来判断一个对象是否是一个已知的类型,类似 type()。
         while True:
             down_url = self.vido.get()  # 获取视频地址
             # output_filename = self.vido_download_name.get()  # 获取视频名字
             print(down_url.replace("'", ""))
             thunder = Dispatch('ThunderAgent.Agent64.1')
             thunder.AddTask(down_url.replace("'", ""))
             thunder.CommitTasks()
             self.vido.task_done()
             # self.vido_download_name.task_done()
     else:
         print('no such process...')
         os.system(r'E:\SoftWare\Program\Thunder.exe')
         self.download()
示例#11
0
文件: cite.py 项目: 928082786/Cite
        def getFile(title, url):
            from win32com.client import Dispatch
            import shutil
            import os

            thunder = Dispatch('ThunderAgent.Agent64.1')
            thunder.AddTask(url, title)
            time.sleep(0.5)
            thunder.CommitTasks()

            loop = True
            while (loop):
                try:
                    downloadRoot = 'D:\迅雷下载'
                    files = os.listdir(downloadRoot)
                    for file in files:
                        if file.endswith('.pdf'):
                            src_path = os.path.join(downloadRoot, file)
                            dst_path = os.path.join('./download_papers', file)
                    shutil.move(src_path, dst_path)
                    loop = False
                except:
                    time.sleep(2)
                    loop = True
示例#12
0
import time
import hashlib
import os
from modules.db_handler import db_handler
from win32com.client import Dispatch

db = db_handler("192.168.7.201")
thunder = Dispatch('ThunderAgent.Agent64.1')
sleep_time = 60
tmp_dir = "c:\\temp\\"
while True:
    for task in db.FindMovie(downstat=0):
        if task["platform"] == "btbtt.com":
            fn = tmp_dir + task["torrent"]["name"]
            print(fn)
            f = open(fn, "wb")
            f.write(task["torrent"]["content"])
            f.close()
            thunder.AddTask(fn)
            thunder.CommitTasks()
            #os.remove(fn)
            exit()
        elif task["platform"] == "dytt8.net":
            print("implementing...")

        time.sleep(2)

    print("all task added. sleep for", sleep_time)
    time.sleep(sleep_time)
示例#13
0
from win32com.client import Dispatch

thunder = Dispatch('ThunderAgent.Agent64.1')
# ThunderAgent.Agent.1 低版本可以试试这个
# AddTask("下载地址", "另存为文件名", "保存目录", "任务注释", "引用地址", "开始模式", "只从原始地址下载", "从原始地址下载线程数")
thunder.AddTask(
    'ftp://*****:*****@yg45.dydytt.net:8129/阳光电影www.ygdy8.com.蝙蝠侠:哥谭骑士.BD.720p.中英双字幕.mkv',
    'movie.mkv')
thunder.CommitTasks()
示例#14
0
i = j = 0
count = 0  # 计数有多少个图片
begin = int(time.time())  # 好奇算一下时长
while k <= end:  # 至于要爬多少你自己定了
    URL = "https://www.pixiv.net/ajax/search/artworks/" + keyword + "?word=%E7%A7%81%E3%81%AB%E5%A4%A9%E4%BD%BF%E3%81%8C%E8%88%9E%E3%81%84%E9%99%8D%E3%82%8A%E3%81%9F&order=date_d&mode=all&p=" + str(
        k) + "&s_mode=s_tag&type=all"
    headers = {"cookie": cookie, "user-agent": UA, "referer": URL}
    session = requests.get(URL, headers=headers)
    print("获得" + URL + "的JSON数据")
    JSON = session.json()
    session.close()
    while i < len(JSON["body"]["illustManga"]["data"]):
        ID = JSON["body"]["illustManga"]["data"][i]["id"]
        URL = "https://www.pixiv.net/ajax/illust/" + ID + "/pages?lang=zh"
        session = requests.get(URL, headers=headers)
        print("\t获得" + URL + "的JSON数据")
        JSON1 = session.json()
        session.close()
        while j < len(JSON1["body"]):
            URL = JSON1["body"][j]["urls"]["original"]
            api.AddTask(URL)
            print("将" + URL + "加入到待下载队列")
            count += 1
            j += 1
        j = 0
        i += 1
        time.sleep(0.5)
    i = 0
    k += 1
api.CommitTasks()
print("共抓取" + str(count) + ",时长" + str(int(time.time()) - begin) + "秒")
示例#15
0
# Código para el proyecto de imágenes
# Este starter code lo proporciona el mismo repositorio del challenge
import nibabel as nib
from starter_code.utils import load_case
from starter_code.visualize import visualize

volume, segmentation = load_case(0)
visualize("case_00003", im1)

from win32com.client import Dispatch

o = Dispatch("ThunderAgent.Agent64.1")
for i in range(210):
    url1 = 'https://media.githubusercontent.com/media/neheller/kits19/master/data/case_%05d/imaging.nii.gz' % i
    url2 = 'https://media.githubusercontent.com/media/neheller/kits19/master/data/case_%05d/segmentation.nii.gz' % i
    filename1 = 'imaging_%03d.nii.gz' % i
    filename2 = 'segmentation_%03d.nii.gz' % i
    o.AddTask(url1, filename1)
    o.AddTask(url2, filename2)
o.CommitTasks()

# %%
示例#16
0
                        movie["magnet"] = movie["magnet"][:movie["magnet"].
                                                          find("&")]

            if ("name_chn" in movie) and (langid.classify(
                    movie["name_chn"][0])[0] != 'zh') and (langid.classify(
                        movie["name"][0])[0] == 'zh'):
                # switch chinese and english name if a opposite name dict is detected
                print("switching name_chn and name.")
                tmp = movie["name"]
                movie["name"] = movie["name_chn"]
                movie["name_chn"] = tmp

            movie["downlink"] = moviepage.select("div#Zoom p table a")[0].get(
                "href")
            movie["name_folder"] = movie["name"][0].replace(" ", "_").replace(
                "#", "_").replace(":", "_").replace("~", "_") + "(" + str(
                    movie["year"]) + ")"

            print(movie)
            db.insert(movie)

        print("Page search complete! start downloading")
        for task in db.search(Query().stat_down == 0):
            print(task)
            thunder.AddTask(task["downlink"])
            thunder.CommitTasks()
            db.update({"stat_down": 1}, Query().dyttid == task["dyttid"])
            time.sleep(2)
    print("all scan finished. wait for ", time_sleep, "s")
    time.sleep(time_sleep)