# -*- coding: utf-8 -*- ''' 1.先自己下载一次 2.再找出付费请求 http://pic.netbian.com/downpic.php?id=24780&classid=66 3.但只能下载一次 4.自己换个新登录账号,只登录不下载,取登录首页的cookie,这样生成的cookie会保持下载可用状态。再加新号cookie模拟下载,注意所有的请求均加新号cookie ''' from pyquery import PyQuery as pq import requests from threading import Thread headers={ 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/82.0.4068.4 Safari/537.36', 'Cookie':'your long cookie' } #首页请求,获取图片id号 def Index(page): #pass#占位符 url='http://pic.netbian.com/index_{}.html'.format(page) response=requests.get(url,headers=headers).content.decode('gbk') #print(response) doc=pq(response) #类选择器,有空格 clearfix=doc('.slist .clearfix li a').items() for i in clearfix: url_data=i.attr('href') #print(url_data)#/tupian/25583.html #print(url_data[8:-5])#切片 id=url_data[8:-5] Image(id) count=1 #模拟请求 def Image(id): global count uri='http://pic.netbian.com/downpic.php?id={}&classid=55'.format(id) res=requests.get(uri,headers=headers) #图片是16进制,ab文件追加 print(res.content) with open('video/{}.jpg'.format(count),'ab') as f: count+=1 f.write(response.content) print('在下载{}'.format(count)) for i in range(1,3): #Index(i) #创建线程,不要括号。以下程序功能相当于Index(i) t=Thread(target=Index,args=(i,)) t.start()
python多线程PyQuery破解付费高清图片下载
阅读:3283 输入:2020-03-29 08:23:05