Manga automatic download tool.

The comic pictures are too beautiful and I want to save them in batches, but there is no interface for batch saving. What can I do? Do I want to order them one by one? That is impossible, teach you how to quickly get comic pictures.

 

Get comic picture ideas

There are too many cartoon pictures. If the network goes down, there will be nothing. After a period of time, the cartoons that were originally free are suddenly not free. What can I do?

 

The answer is simple. You can watch it even after it is disconnected from the Internet. How can this be done? The first thing I think of is the crawler. Use the crawler to get the url of the picture, and then use the save and file save, so that all the pictures can be obtained, and then all the comic pictures are obtained. Think about whether there is any movement.

 

Let me give you a scene first. If you say that comics will suddenly be charged after a period of time, but your comics can still be read, is this a pleasure? Then you can say to those who like comics, hello! I have this comic. Would you like to buy it for 20 yuan?

Code

 

The following is the implementation process of the code:

import re
import os
import requests
import time
import random

class kumiean():
def __init__(self):
    self.f="D:\\漫画\\"
    self.list=['Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1','Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50','Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11',
                'Mozilla/5.0(Macintosh;U;IntelMacOSX10_6_8;en-us)AppleWebKit/534.50(KHTML,likeGecko)Version/5.1Safari/534.50',
                'Mozilla/5.0(Windows;U;WindowsNT6.1;en-us)AppleWebKit/534.50(KHTML,likeGecko)Version/5.1Safari/534.50',
                'Mozilla/5.0(compatible;MSIE9.0;WindowsNT6.1;Trident/5.0;',
                'Mozilla/4.0(compatible;MSIE8.0;WindowsNT6.0;Trident/4.0)',
                'Mozilla/5.0(WindowsNT6.1;rv:2.0.1)Gecko/20100101Firefox/4.0.1',
                'Opera/9.80(Macintosh;IntelMacOSX10.6.8;U;en)Presto/2.8.131Version/11.11',
                'Mozilla/5.0(Macintosh;IntelMacOSX10_7_0)AppleWebKit/535.11(KHTML,likeGecko)Chrome/17.0.963.56Safari/535.11',
                'Mozilla/4.0(compatible;MSIE7.0;WindowsNT5.1;TencentTraveler4.0)',
                'Mozilla/4.0(compatible;MSIE7.0;WindowsNT5.1;Trident/4.0;SE2.XMetaSr1.0;SE2.XMetaSr1.0;.NETCLR2.0.50727;SE2.XMetaSr1.0)',
                'Mozilla/4.0(compatible;MSIE7.0;WindowsNT5.1;360SE)',
                'Mozilla/4.0(compatible;MSIE7.0;WindowsNT5.1;Trident/4.0;InfoPath.2;.NET4.0C;.NET4.0E;.NETCLR2.0.50727;360SE) ',
                'Mozilla/5.0(iPhone;U;CPUiPhoneOS4_3_3likeMacOSX;en-us)AppleWebKit/533.17.9(KHTML,likeGecko)Version/5.0.2Mobile/8J2Safari/6533.18.5',
                'Mozilla/4.0(compatible;MSIE7.0;WindowsNT5.1;Trident/4.0;TencentTraveler4.0;.NETCLR2.0.50727)',
                'Opera/9.80(Android2.3.4;Linux;Operamobi/adr-1107051709;U;zh-cn)Presto/2.8.149Version/11.10']
    self.headers = {
                    'User-Agent': random.choice(self.list)
                    }
def url_4(self,url1):
    """获取本漫画的所有章节url"""
    time.sleep(random.uniform(1, 4))
    html = requests.get(url1, headers=self.headers)
    ti = r'''<a href="(.*?)" title="(.*?)" target="_blank" style="max-width: 200px;">.*?</a>'''
    url = re.findall(ti, html.text)
    if url==[]:
         pass
    else:
        for j in set(url):
            self.f_3=self.f_2+"\\" + j[1]
            if os.path.isdir(self.f_3)==True:
                continue
            else:
                try:
                    os.mkdir(self.f_3)
                except:
                    continue
            self.url_5(j[0])
def url_5(self,url1):
    """保存该漫画的本话的所有图片"""
    html = requests.get(url1, headers=self.headers)
    ti = r'''<li style="margin-top: -3.6px"><span><img src="(.*?)" data-image_id="\d+" id="image_\d+"></span></li>'''
    url = re.findall(ti, html.text)
    if url == []:
        print("vip章节,不能获取到目录")
        return
    else:
        for j, url3 in enumerate(url):
            f_4=self.f_3+"\\" + str(j) + ".jpeg"
            if os.path.exists(f_4)==True:
                continue
            else:
                ht = requests.get(url3, headers=self.headers).content
                with open(f_4, "wb") as f:#写入文件中
                    f.write(ht)

 

 

Well, the above is all the code. In addition, for the convenience of use, a software is specially made and packaged. You only need to enter the URL address you want to grab to easily get the comics.

 

Note: This software is only suitable for personal use, please do not use it for commercial purposes.

 

 

Welcome to follow the official account, the public backstage reply " download comics " to get the link to the network disk, there are more interesting software waiting for you to discover.

O ^ ~ ^ O

 

related suggestion……………………

 

Automatic generation of word cloud, look

Python implements blessing bullet frame

WeChat add friends automatically

 

Guess you like

Origin blog.csdn.net/qq_39046854/article/details/83066050