吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2215|回复: 1
收起左侧

[会员申请] LiangMo

  [复制链接]
吾爱游客  发表于 2021-12-5 16:28
申请标题:申请会员ID:LiangMo

1、申 请 I D:LiangMo
2、个人邮箱:2434672036@qq.com

自己写了一个关于Python爬虫的程序

爬虫写的是下载某网站的小姐姐图片

保存地址为D:/Python照片输出/meizi/

源码为:
[Python] 纯文本查看 复制代码
import requests
from bs4 import BeautifulSoup

headers = {
    "referer": "https://www.mzitu.com/",
    "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36"
}

response = requests.get('https://www.mzitu.com/', headers=headers)
infos = response.text
soup = BeautifulSoup(infos, 'lxml')
photos = soup.select('#pins>li>a')
name = 0
for photo in photos:
    name += 1
    dizhi = photo['href']
    response = requests.get(dizhi, headers=headers)
    infos = response.text
    soup = BeautifulSoup(infos, 'lxml')
    wei = soup.select('.pagenavi>a')[-2].select('span')[0].text
    wei = int(wei)
    for i in range(1, wei):
        response = requests.get(dizhi + '/{}'.format(i), headers=headers)
        infos = response.text
        soup = BeautifulSoup(infos, 'lxml')
        # e = etree.HTML(response.text)
        urls = soup.select('.main-image>p>a>img')[0]
        url = urls['src']
        response = requests.get(url, headers=headers)
        with open('D:Python照片输出//meizi//{}.jpg'.format(str(name) + '.' + str(i)), 'wb') as f:
            print('正在下载{}'.format(str(name) + '.' + str(i)))
            f.write(response.content)
            print('{}下载完成'.format(str(name) + '.' + str(i)))




发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Hmily 发表于 2021-12-6 10:26
抱歉,未能达到申请要求,申请不通过,可以关注论坛官方微信(吾爱破解论坛),等待开放注册通知。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-11-14 14:49

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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