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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Ubuntu下Lapack安装教程

    Ubuntu下Lapack安装教程记录程序人生环境:linux我用的是ubuntu16.04具体步骤:1.下载Seismicunix安装包//DownloadthelatestLapackhttp://www.netlib.org/lapack/#_lapack_version_3_9_0_2得到lapack-3.9.0.tar.gz,然后用tar-zxvflapack-3.9.0.tar.gz进行解压。2.安装必要的依赖包//installthenecessarypackag

    2025年6月16日
    1
  • class文件与dex文件解析

    class文件与dex文件解析这篇笔记是我去年的时候创建的,结果放到草稿箱里给忘记了,大写的尴尬啊,所以急忙给补上了,此处鄙视一下自己!今天的正题——解析class文件和dex文件。

    2022年6月27日
    79
  • translate函数用法_fork函数在循环体中

    translate函数用法_fork函数在循环体中TranslateMessage函数函数功能描述:将虚拟键消息转换为字符消息。字符消息被送到调用线程的消息队列中,在下一次线程调用函数GetMessage或PeekMessage时被读出。.函数原型:   BOOLTranslateMessage( CONSTMSG*lpMsg);.参数:   lpMsg       指向一个含有用GetMessage或PeekMe

    2025年11月5日
    4
  • C语言模拟银行家算法

    C语言模拟银行家算法银行家算法需求:一个程序对资源的最大需求量不超过系统的最大资源程序可以分多次申请资源,但是申请资源的总量不能超过最大需求量当系统现有资源不能满足程序的需求时,可以推迟分配资源,但是总能满足程序对资源的需求当程序获得了全部的资源后,要在有限的时间内归还资源系统的安全/不安全状态:在程序申请资源时,当系统的拥有的资源不能满足程序剩余所需的全部资源时,则处于不安全状态C代码实现:头文件的导入和预定义#include<stdio.h>#include<stdli

    2022年7月22日
    6
  • 常用meta整理

    常用meta整理

    2021年9月7日
    59
  • Vue 数组操作

    Vue 数组操作Vue 数组操作

    2022年4月23日
    115

发表回复

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

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