Python漫画下载器「建议收藏」

Python漫画下载器「建议收藏」“并不是所有数据都应该被获取。”——弗罗指令,53.12很多漫画找不到下载资源了(可能被亚空间吞没了吧),无奈只能从漫画网站上扒了。但一页一页右键保存太浪费资源与时间了,所以写了个Py爬虫扒图片吧~~赞美虚空龙,额,我是说万机神~#coding:utf-8#!/usr/bin/envpython3#=========================================================##漫画下载##================..

大家好,又见面了,我是你们的朋友全栈君。

“并不是所有数据都应该被获取。”

—— 弗罗指令,53.12

 

很多漫画找不到下载资源了(可能被亚空间吞没了吧),无奈只能从漫画网站上扒了。但一页一页右键保存太浪费资源与时间了,所以写了个Py爬虫扒图片吧~~赞美虚空龙,额,我是说万机神~

 

# coding:utf-8

#!/usr/bin/env python3

#=========================================================
#
# 漫画下载
#
#=========================================================

#                                            ;@#@@$|;'`.                                            `
#                                            ;@#############&|:`                                    `
#                                            ;@####################|`                               `
#                                            ;@####################@@##$:                           `
#                                            :@#@#########################@!.                       `
#                                      .%####$;::;$###########################|.                    `
#                                      .%####|    |#############################&:                  `
#                       .;&#%.         .%####|    |###########$!$##################|.               `
#                    '&##@##@$`        `%####|    |#@@#######%.    '$################|              `
#                 `%##########&: `:|&########|     .`:%#####%.        `$##############@;            `
#                  :&#############@@#########|                       .%###############@@$'          `
#                   '$#######################|                      .|###################@!.        `
#                    `$#############@########%.                    .|######################$`       `
#                   !##############@|'       :@#####&!'             .!@#####################&`      `
#       .%@;.     |#############%`           ;######@@###$`            ;@##################@@&'     `
#      :&#####&:|##########@#&:              ;@#############$.           ;@#&;`   |###########&:    `
#     |########@###########&'                :@#############@#$`                   '&##########&'   `
#    !####################|.                 :@################@;                   '&##########$`  `
#   ;@@@#################!                   :@##################|                   ;@##########|  `
#     '$@###############!                    :@##################@;               ;&#############@: `
#        .%############$`                    :@###################$`           `$#@###############%.`
#        `$############|                     :@###################&'            |#################@:'
#        |#############|                     :@###################@:            '&#################|:
#       `$#############|.                    :@###################&'             |#################$!
#   ...`%##############&'                    :@#################@#%.             '$################@%
#&######################$.                   :@##################&:                      |##########$
#&#######################|                   :@#################@;                       ;@#########$
#&#######################@:                  :@#################%.                       :@#########$
#&########################|                  ;@#################!                        !##########$
#@########################|                  ;@#########@@@@#@#@;                       `%##########$
#       ;@###############$`    `::`          :@####@@###$:';&###&'               '&################@%
#       .%##############|    `$#@@###$;`.    ;@@##&|:        ;@##@:             .%#################$!
#        !#############&:    `$#######@@@#%. :@@;            |####|.            ;@#################|'
#        .%#############&:    :@#@@@##@%'    :@##@!`        '$#@@%`            .%#################@:'
#        :$##############&:    .::`.        :;;&######@%!:;$##@@%.             '$#################%.`
#    .;@##################|                ;@! `&######@@#@#####!                 '%##@##########&: `
#   '&@@###################!              `$#!  !#########@#@@#|                     |###########|  `
#    :@#####################&!'`:!|'      '' :@$!&#####$``;!;'                      ;@##########$`  `
#     :@#####################@#@@#|          ;&@########|                          |###########&'   `
#      `$#@##@|.'%#############@#$`          ;@########@$'              '%###$'  .%###########&:    `
#       .|$:      '$#############%.       .  ;@#$|&##@@#&:            `$#####################&'     `
#                   `%###########!  .'.  |!  ;##%:%#&;$##|          '$######################&'      `
#                    '$######################|.                     ;######################%.       `
#                   |########################|.                      '&##################@!         `
#                  %################@@#######|           `;:.         `$##############@@%`          `
#                 .|##@#####@#%.   `:|$@#####|    '|&####@&#$        .|@############@@&'            `
#                     :&###@@|.        .%####|    |##########&'   `%##@###########@@&:              `
#                        `|@|          .%####|    |############@@#################&:                `
#                                      .$#@@#|    |###########################@#%`                  `
#                                       :|%$&$$&&&###########################$'                     `
#                                            :@#@######################@@#$'                        `
#                                            :@###################@###$;.                           `
#                                            :@############@@####@|'                                `
#                                            ;@#@@########@%;'.                                     `
#
# "There is no truth in flesh, only betrayal."
# "There is no strength in flesh, only weakness."
# "There is no constancy in flesh, only decay."
# "There is no certainty in flesh but death."
# — Credo Omnissiah
#

#转utf8中文
#import io
#import sys
#import cv2
#import numpy as np
#sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='utf-8')

import os
import urllib.request
import logging
import sys

import threading
from concurrent.futures import ThreadPoolExecutor

##同时运行线程数目
threadCount = 20
pool = ThreadPoolExecutor(threadCount)

#下载和存储地址
downloadURL = "https://xxxxxxx/xxxxx/"
downloadPath = "PATH/download/"

#最大页码
maxPageCount = 200

logging.basicConfig(
    format='%(asctime)s %(levelname)s %(message)s',
    level=logging.INFO,
    stream=sys.stdout)

opener = urllib.request.build_opener()
opener.addheaders = [("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1941.0 Safari/537.36"),
                     ("Referer", "https://xxxxxxx/")]

def down(_save_path, _url):
    try:
        #伪装
        urllib.request.install_opener(opener)
        urllib.request.urlretrieve(_url, filename=_save_path)
    except:
        print('Error when retrieving the URL:', _save_path)


def downloadAtIndex(index):
    file_path = downloadPath + str(index) + ".jpg"
    url = downloadURL + str(index) + ".jpg"

    if not os.path.isfile(file_path):
        # if dir 'dir_name/' doesn't exist
        file_dir = file_path[:-9]
        if not os.path.exists(downloadPath):
            os.mkdir(downloadPath)

        print("Downloading file", file_path)
        down(file_path, url)
    else:
        logging.info("File exists.")
    print(file_path," Done \n")


for i in range(1, maxPageCount):
    #多线程下载
    task = pool.submit(downloadAtIndex, (i))
    #单线程下载
#    downloadAtIndex(i)

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/148196.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • windows 如何安装ffmpeg[通俗易懂]

    windows 如何安装ffmpeg

    2022年2月20日
    64
  • TCP报文段格式[通俗易懂]

    三次握手就是一次TCP建立链接的过程四次挥手就是一次TCP断开的过程所以在学习三次握手四次挥手之前先了解一下TCP报文段的格式源端口(2字节):发送端应用程序的端口号,与源IP地址确定一个唯一地址目的端口(2字节):接收端计算机应用程序的端口号,与目的IP地址确定唯一的地址序号(4字节):TCP是面向字节流传输的,他为每一个字节编了一个序号,该报文段中序号为传输数据第一个字节的序号,例如:一个报文…

    2022年4月17日
    88
  • 浅析@MapperScan原理[通俗易懂]

    浅析@MapperScan原理[通俗易懂]@MapperScan是spring用于批量注入mybatis映射器(DAO接口)的注解。与之相对应@Mapper进行单个注册。源码如下:@Retention(RetentionPolicy.RUNTIME)@Target(ElementType.TYPE)@Documented@Import(MapperScannerRegistrar.class)@Repeatable(MapperScans.class)public@interfaceMapperScan{//指定

    2022年5月26日
    136
  • css选择器有哪些?[通俗易懂]

    css选择器有哪些?[通俗易懂]一、写在前面css选择器有很多,但是常用到的也就几个,今天总结一下。二、具体选择器2.1、id选择器#myId{}2.2、类选择器.myClass{}2.3、标签选择器p,h1{}2.4、后代选择器divh1{}2.5、子选择器div>h1{}2.6、兄弟选择器(所有的兄弟)ul~h1{}2.7、相邻兄弟选择器ul+h1{}2.8、属性选择器li[name=’sss’]{}2.9、伪类选择器h1:hover{}2.10h

    2022年10月22日
    0
  • subprocess的用法[通俗易懂]

    subprocess的用法[通俗易懂]从python2.4版本开始,可以用subprocess这个模块来产生子进程,并连接到子进程的标准输入/输出/错误中去,还可以得到子进程的返回值。subprocess意在替代其他几个老的模块或者函数,比如:os.systemos.spawn*os.popen*popen2.*commands.*一、subprocess.Popensubprocess模块定义了一个类:Popenc…

    2022年10月23日
    1
  • Lighttpd 插件mod_h264 streaming (mp4)安装

    Lighttpd 插件mod_h264 streaming (mp4)安装

    2022年3月5日
    34

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号