鱼C论坛

 找回密码
 立即注册
查看: 2179|回复: 6

[作品展示] 妹子图的源码,包括出来错误信息,加上进程池,加上IP替换,加上进度条

[复制链接]
发表于 2019-7-6 15:25:14 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 python_mysql 于 2019-7-7 10:23 编辑
  1. import urllib3,random,os
  2. from tqdm import tqdm
  3. from lxml import etree
  4. import requests,time
  5. from multiprocessing import Pool
  6. class Open_go(object):
  7.     def ip_proxy(self):
  8.         if self.getProxyIp() != []:
  9.             ip = self.getProxyIp()[random.randrange(0, len(self.getProxyIp()))]
  10.             proxy_ip = 'http://' + ip
  11.             proxies = {'http': proxy_ip}
  12.             return proxies
  13.         else:
  14.             print('代理列表获取失败')
  15.     def getProxyIp(seif):
  16.         try:
  17.             proxy = []
  18.             for i in range(1, 5):
  19.                 url = 'https://www.kuaidaili.com/free/inha/{}/'.format(i)
  20.                 headers = {
  21.                     'Cookie': 'channelid=0; sid=1559955051965303; _ga=GA1.2.885541243.1559956488; _gid=GA1.2.474522862.1559956488; Hm_lvt_7ed65b1cc4b810e9fd37959c9bb51b31=1559956487,1559971332; Hm_lpvt_7ed65b1cc4b810e9fd37959c9bb51b31=1559971354',
  22.                     'Host': 'www.kuaidaili.com',
  23.                     'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'
  24.                 }
  25.                 response = requests.get(url, headers=headers)
  26.                 html = etree.HTML(response.text)
  27.                 ip = html.xpath('//td[@data-title="IP"]/text()')
  28.                 ip_port = html.xpath('//td[@data-title="PORT"]/text()')
  29.                 for x, z in zip(ip, ip_port):
  30.                     name_ip_port = x + ':' + z
  31.                     proxy.append(name_ip_port)
  32.             return proxy
  33.         except:
  34.             print('代理没有获取到。')
  35.     def nameMei(self):
  36.         print('马上开始挑选你们的妹子图片吧')
  37.         time.sleep(3)
  38.         proxies = {
  39.             "http": "http://{}".format(self.ip_proxy),
  40.             # "https": "https://221.228.17.172:8181",
  41.         }
  42.         url='https://www.mzitu.com/tag/youhuo/'
  43.         headers={
  44.         'cookie': 'Hm_lvt_dbc355aef238b6c32b43eacbbf161c3c=1559885691; Hm_lpvt_dbc355aef238b6c32b43eacbbf161c3c=1559885733',
  45.         'upgrade-insecure-requests': '1',
  46.         'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'
  47.         }
  48.         html =requests.get(url,headers=headers,proxies=proxies)
  49.         if html.status_code == 200:
  50.             print('很成功的,我们程序没有被屏蔽,(╥╯^╰╥)')
  51.             time.sleep(2)
  52.             html_xpath=etree.HTML(html.text)
  53.             url_html=html_xpath.xpath('//div[@class="footer"]/a/@href')
  54.             url_html_text=html_xpath.xpath('//div[@class="footer"]/a/text()')
  55.             for H_url,T_tex in zip(url_html[1:-1],url_html_text[1:-1]):
  56.                 print(T_tex)
  57.             try:
  58.                 x=4
  59.                 while x>=1:
  60.                     name = input('请输入你您要下载的图片是:')
  61.                     if name.isalnum() or  name =='':
  62.                         if name in url_html_text:
  63.                             name_url=url_html_text.index(name)
  64.                             url_data=url_html[name_url]
  65.                             self.cenmMsibo(url_data,name)
  66.                         else:
  67.                             print('请认真对待我们的程序哦')
  68.                     elif str(name) == '1':
  69.                         return
  70.                     else:
  71.                         print('请输入正确的美女图片'+'您还有%s机会'%(x))
  72.                     x-=1
  73.             except:
  74.                 print('程序错误等待更新。')
  75.         else:
  76.             print('错误访问')
  77.     def cenmMsibo(self,url_data,name):
  78.         print(name+'美女很多要好好看哦')
  79.         time.sleep(3)
  80.         html_URL = urllib3.PoolManager()
  81.         headers = {
  82.             'cookie': 'Hm_lvt_dbc355aef238b6c32b43eacbbf161c3c=1559885691; Hm_lpvt_dbc355aef238b6c32b43eacbbf161c3c=1559885733',
  83.             'upgrade-insecure-requests': '1',
  84.             'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'
  85.         }
  86.         html = html_URL.request('GET', url_data, headers=headers)
  87.         if html.status ==200:
  88.             name_html = html.data.decode('utf-8')
  89.             html_xpath = etree.HTML(name_html)
  90.             ul_html=html_xpath.xpath('//ul[@id="pins"]/li/a/@href')
  91.             ul_txt=html_xpath.xpath('//ul[@id="pins"]/li/a/img/@alt')
  92.             for  i ,x in zip(ul_txt,range(0,30)):
  93.                 print(str(x)+':'+i)
  94.             try:
  95.                 x=4
  96.                 while x>=1:
  97.                     name=input('请输入你要下载美女的图片的数字:')
  98.                     if name.isalnum() or name =='':
  99.                         url000=ul_html[int(name)]
  100.                         P = Pool()
  101.                         P.apply_async(self.domowoer(url000))
  102.                         P.close()
  103.                     else:
  104.                         print('您输入有错了,还有%s次机会'%(x))
  105.                     x-=1
  106.                     print('阻塞程序')
  107.                     P.join()
  108.                     
  109.             except:
  110.                 print('程序错误,等待更新')
  111.         else:
  112.             print('访问错误')
  113.     def domowoer(self,url000):
  114.         print('开始下载了哦')
  115.         time.sleep(3)
  116.         for i  in range(2,50):
  117.             wenjian='妹子图'
  118.             html_url_name=url000+'/%s'%(i)
  119.             html_URL = urllib3.PoolManager()
  120.             headers = {
  121.                 'cookie': 'Hm_lvt_dbc355aef238b6c32b43eacbbf161c3c=1559885691; Hm_lpvt_dbc355aef238b6c32b43eacbbf161c3c=1559885733',
  122.                 'upgrade-insecure-requests': '1',
  123.                 'user-agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'
  124.             }
  125.             html = html_URL.request('GET', html_url_name, headers=headers)
  126.             if html.status == 200:
  127.                 name_html = html.data.decode('utf-8')
  128.                 html_xpath = etree.HTML(name_html)
  129.                 main_title=html_xpath.xpath('//h2[@class="main-title"]/text()')
  130.                 main_img=html_xpath.xpath('//div[@class="main-image"]/p/a/img/@src')
  131.                 wenjianming=''.join(main_title)
  132.                 if not os.path.exists(wenjian):
  133.                     os.makedirs(wenjian)
  134.                 if not os.path.exists(wenjian+'\\'+wenjianming[8:19]):
  135.                     os.mkdir(wenjian+'\\'+wenjianming[8:19])
  136.                 if main_img!=[]:
  137.                     url = ''.join(main_img)
  138.                     headers = {
  139.                         'referer':'https://www.mzitu.com/177079/2',
  140.                         'upgrade-insecure-requests':'1',
  141.                         'cookie':'UM_distinctid=16b3128b8341-0d238ded195901-4048032c-100200-16b3128b8353f4; Hm_lvt_dbc355aef238b6c32b43eacbbf161c3c=1559885691,1559901291,1559971044; Hm_lpvt_dbc355aef238b6c32b43eacbbf161c3c=1559976366',
  142.                         'user-agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36'
  143.                     }
  144.                     html1 = requests.get(url, headers=headers)
  145.                     try:
  146.                         if html1.status_code == 200:
  147.                             for i in tqdm(range(1,101)):
  148.                                 time.sleep(0.001)
  149.                             time.sleep(2)
  150.                             pinjie=wenjian+'\\'+wenjianming[8:19]+'\\'
  151.                             name_int=random.randint(1,200)
  152.                             f=open(pinjie+str(name_int)+'.jpg','wb')
  153.                             f.write(html1.content)
  154.                             f.close()
  155.                         else:
  156.                             print('下载失败'+url)
  157.                     except:
  158.                         print('网站获取失败等待更新')
  159.                         print('重新调用程序')
  160.                         time.sleep(5)
  161.                         self.nameMei()
  162.             else:
  163.                 print('抱歉,网站不存在'+str(html_url_name))
  164.                 print('重新调用程序')
  165.                 time.sleep(5)
  166.                 self.nameMei()
  167. if __name__ == '__main__':
  168.     print('--- ---    欢迎下载妹子图,热烈欢迎 --- ---')
  169.     time.sleep(3)
  170.     print('我们有大量的妹子图供你们下载')
  171.     time.sleep(3)
  172.     print('启动程序了哦')
  173.     K_1=Open_go()
  174.     for i in tqdm(range(100)):
  175.         time.sleep(0.05)
  176.     print('成功启动了')
  177.     time.sleep(3)
  178.     K_1.nameMei()


复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2019-7-7 10:20:07 | 显示全部楼层

小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2019-7-7 10:22:04 | 显示全部楼层
这是我对妹子的爬去的 源码 可以直接下载使用
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-7-22 15:17:08 | 显示全部楼层
哥  你知道怎么把自己ip地址改成别的地方的不 不然新疆地区用不了百度网盘
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-8-4 14:25:22 | 显示全部楼层
顶一下
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-7-7 21:41:45 | 显示全部楼层
这个是真的顶,我给您跪下了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2021-9-1 09:53:36 | 显示全部楼层

tkinter怎么加这样的进度条?可以用于生产的
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-19 10:56

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表