import requests, re, winsound
from PIL import Image
r = requests.get('略略略photo/241530/')
jpg_list = jpg_list = re.findall('data-original="(https.*?media.*?jpg.*?\d{10})', r.text)
jiemi=1
def comic_jiemi(fp):
#某漫画网站把图片分割乱序。
image = Image.open(fp=fp)
w, h = image.size
box1 = (0, 0, w, int(h / 10))
box2 = (0, int(h / 10), w, int(h / 10) * 2)
box3 = (0, int(h / 10) * 2, w, int(h / 10) * 3)
box4 = (0, int(h / 10) * 3, w, int(h / 10) * 4)
box5 = (0, int(h / 10) * 4, w, int(h / 10) * 5)
box6 = (0, int(h / 10) * 5, w, int(h / 10) * 6)
box7 = (0, int(h / 10) * 6, w, int(h / 10) * 7)
box8 = (0, int(h / 10) * 7, w, int(h / 10) * 8)
box9 = (0, int(h / 10) * 8, w, int(h / 10) * 9)
box10 = (0, int(h / 10) * 9, w, int(h / 10) * 10)
im1 = image.crop(box1)
im2 = image.crop(box2)
im3 = image.crop(box3)
im4 = image.crop(box4)
im5 = image.crop(box5)
im6 = image.crop(box6)
im7 = image.crop(box7)
im8 = image.crop(box8)
im9 = image.crop(box9)
im10 = image.crop(box10)
flag = Image.new('RGB', (w, h))
flag.paste(im1, (0, 9 * int(h / 10)))
flag.paste(im2, (0, 8 * int(h / 10)))
flag.paste(im3, (0, 7 * int(h / 10)))
flag.paste(im4, (0, 6 * int(h / 10)))
flag.paste(im5, (0, 5 * int(h / 10)))
flag.paste(im6, (0, 4 * int(h / 10)))
flag.paste(im7, (0, 3 * int(h / 10)))
flag.paste(im8, (0, 2 * int(h / 10)))
flag.paste(im9, (0, 1 * int(h / 10)))
flag.paste(im10, (0, 0))
#fp = 'C:\\Users\\Administrator\\Desktop\\3\\'+name
flag.save(fp=fp)
image.close()
session = requests.session()
# session 肉眼可见的快,比对直接r2 = requests.get()
for i in jpg_list:
print(i)
r2 = session.get(i)
print(r2.status_code)
name = i.split('/')[-1].split('?')[0]
with open('F:\\18comic\\3d+cn\\3\\' + name, 'wb')as f:
f.write(r2.content)
print(len(r2.content))
fp = 'F:\\18comic\\3d+cn\\3\\' + name
if jiemi:
comic_jiemi(fp)
winsound.Beep(600, 1000)
保存网页图片
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 1、用鼠标右键的“另存为”: 把图片用鼠标左键抹灰,或者是用鼠标左键单击图片→接着单击鼠标右键→选择"图片另存为"...