splash PNG臭虫

2024-05-28 18:43:32 发布

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

蜘蛛:

import scrapy
from scrapy_splash import SplashRequest


class TestSpider(scrapy.Spider):
    name = 'test'

    def start_requests(self):
        splash_args = {
            'png': 1,
            'render_all': 1,
            'wait': 2,
        }
        url = 'https://google.com'
        yield SplashRequest(
            url,
            callback=self.parse_splash,
            endpoint='render.png',
            args=splash_args
        )
        yield scrapy.Request(
            f"http://localhost:8050/render.png?url={url}&wait=2&render_all=1",
            self.parse_request,
        )

    def parse_request(self, response):
        with open('request.png', 'wb') as f:
            f.write(response.body)

    def parse_splash(self, response):
        with open('splash.png', 'wb') as f:
            f.write(response.body)

问题:与恶心。请求好吧,不过飞溅.png我看到的不是Google页面截图。SplashRequest怎么了?在

enter image description here

添加了p.S.Issue


Tags: importselfurlpngparseresponserequestdef

热门问题