未在.jl fi中显示的刮伤元素

2024-10-08 22:26:31 发布

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

快速背景我正在学习用Python编写代码,同时学习刮。我这里的问题是,当我运行这段代码时,控制台显示确实需要的内容被刮去了,但是当我打开.jl文档时,它是空的。作为一个初学者,我可能错过了很多东西。谢谢你的帮助,如果我错过了一个类似的职位提前道歉。你知道吗

import scrapy

class ProgxSpider(scrapy.Spider):
    name = 'progx'
    allowed_domains = ['random.com']
    start_urls = ['https://www.random.com.html']


    def parse(self, response):
         locations = []

        for i in response.selector.xpath('//div[@class="property-info- 
location ellipsis-element-control"]/text()').extract():
            locations.append(i)
        print(locations)

Tags: 代码文档importcom内容response职位random

热门问题