抓取器如何提取未选择的字段的文本

2024-06-11 21:19:57 发布

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

我是python/scrapy的新手。我的问题类似于这个问题,但我不能很好地构思出一个有效的答案:

How Scrapy extract text inside class that inside attribute?

这是我的密码:

import scrapy

class IndeedSpider(scrapy.Spider):
    name='indeed_jobs'
    start_urls = ['https://www.indeed.com/q-Software-Engineer-l-Portland,-OR-jobs.html']

    def parse(self, response):
        next_page_outer = './/link[@rel="next"]'
        next_page_url_outer = response.xpath(next_page_outer).get()
        print(next_page_url_outer)  

该代码产生:

<link rel="next" href="/jobs?q=Software+Engineer&amp;l=Portland%2C+OR&amp;start=10">

如何从该响应中包含的href中获取文本?谢谢!你知道吗


Tags: orresponsepagejobslinksoftwarestartclass