4

如何做 LinkExtractor 使用 SplashRequest 发送请求。
我运行此代码但仅将请求发送到主页,主页的链接没有被提取。

代码:

rules = { Rule(
        LinkExtractor(
            restrict_xpaths=('//ul[contains(@class, "nav-list")]'),
        ),
        callback="parse_item",
        process_request='use_splash'
    )
}

def use_splash(self, request):
    return SplashRequest(url=request.url,
                            endpoint="render.json",
                            args={
                                    "wait":1,
                                    "har": 1,
                                    "html": 1,
                            })
def start_requests(self):
    yield SplashRequest("http://www.example.com",
        callback=self.parse_item,
        endpoint="render.json",
        args={
            "wait":1,
            "har": 1,
            "html": 1,
        })

def parse_item(self):
     # Extract item

编辑有
什么意见吗?

4

0 回答 0