栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

21年10月, 唯美女孩网站爬取,python, requests + re

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

21年10月, 唯美女孩网站爬取,python, requests + re

不多bb,直接上代码

import re
import time

import requests

headers = {
    "user-agent": "写自己的浏览器"
}
response = requests.get('https://www.vmgirls.com/这里五个数.html', headers=headers)    # 只爬详情页
time.sleep(1)


def cunchu(data):
    img_all = re.findall('', data)
    for i in img_all:
        img_url = 'https:' + i
        print(img_url)
        time.sleep(1)
        file = './img/' + i[26:34] + '.jpg'
        img_res = requests.get(img_url, headers=headers)
        with open(file, "wb") as f:
            f.write(img_res.content)


if re.findall('', response.text):
    print("没有跳转")
    cunchu(response.text)
else:
    href = re.findall('.href ="(.*?)";  

重点思路:在请求详情页的时候有可能会遇到跳转页,通过re获取详情页url,继续get。

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/324046.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号