如何抓取有加载程序的网站?

2024-04-26 14:41:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图抓取包含加载屏幕的网站。当我浏览网站时,它显示正在加载。。一秒钟,然后它就装好了。但问题是,当我尝试使用scrapy来刮取它时,它什么也没有给我(可能是因为加载)。我可以用scrapy解决这个问题,还是应该用其他工具? 如果你想看https://www.graana.com/project/601/lotus-lake-towers,这是网站的链接


Tags: 工具httpsprojectcom屏幕网站链接www
1条回答
网友
1楼 · 发布于 2024-04-26 14:41:33

Network console当它发送GET请求以获取有关属性的信息时,您应该在代码中模拟相同的操作。(您可以在控制台->;网络->;XHR下观察GET调用)

    # -*- coding: utf-8 -*-
    import scrapy


    class GranaSpider(scrapy.Spider):
        name = 'grana'
        allowed_domains = 'www.graana.com'
        start_urls = ['https://www.graana.com/api/area/slug/601']

        def parse(self, response):
    #        for url in allurlList:
            scrapy.http.Request(response.url, method='GET' , dont_filter=False)
            print(response.body)
#convert json response to array and save to your storage system

输出是json格式的,请根据需要进行转换。你知道吗

enter image description here

相关问题 更多 >