如何在每个计时器中重新加载scrapy中的响应内容?

2024-04-25 01:05:16 发布

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

我想在每个计时器后检索动态HTML表的内容,但每次取消后的响应总是相同的; 但是我不知道怎么做,所以我对scrapy很陌生;下面是我的代码内容

# redirection sur la page
def parse_x(self,response):

    for q in response.xpath('//*[@id="sessions"]/tbody/tr'):
        # recuperation des informations localisé dans la tableau user_session sur la page
        instance_name = q.xpath('td[2]//text()').extract_first()
        username = q.xpath('td[3]//text()').extract_first()
        client_address = q.xpath('td[4]//text()').extract_first()
        environnement = q.xpath('td[5]//text()').extract_first()
    Timer(5, self.parse_x, [response]).start()

Tags: textself内容parseresponsehtmlpageextract