请问老师,这个网站是不是增加了反爬措施

来源:6-13 【实战】聚美优品:CrawlSpider 爬取并储存商品信息

AShySherry

2023-05-04

老师您好,在抓取聚美优品这个网站的时候碰到了这么一个情况

class JumeiAppSpider(CrawlSpider):
    name = 'jumei_app'
    # allowed_domains = ["search.jumei.com"]
    start_urls = ["http://search.jumei.com/?filter=0-11-1&search=%E5%85%B0%E8%94%BB&from=all_null_index_top_nav_cosmetics&lo=3481&mat=30573"]
    rules = (Rule(LinkExtractor(allow=r"http://item.jumeiglobal.com/.+"), callback="parse_item", follow=True),)

    def parse_item(self, response):
        print("response")
        print(response.url)

根据规则找不到符合的网站,进入不了parse_item,然后我通过普通的方式试了一下这个网站。

import requests
from fake_useragent import UserAgent


ua = UserAgent()

url = "http://search.jumei.com/?filter=0-11-1&search=%E4%BF%9D%E6%B9%BF"
response = requests.get(url, headers={"user-agent": ua.random})
print(response.text)

发现只要是列表类型的网页,打印它的网页源代码时都是空的
图片描述但是打印聚美优品的首页就没有问题,可以返回内容,这是什么原因呢?是不是新增了反爬呢?这是怎么做到的呢?

写回答

1回答

Martin__Wang

2023-05-10

我测试了一下。应该是反扒措施升级了,你带上cookie就好了

0
0

Python 分布式爬虫与 JS 逆向进阶实战

20+ 案例 & 可接单级项目,全面提升爬虫实战能力

99 学习 · 26 问题

查看课程