为什么每行之间的CSV之间都有空格?

2024-04-26 20:55:00 发布

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

当我在命令行中运行此代码时;scrapy crawl-o项目.csv,我收到一个输出,每行之间有空格。请参见图片。我该怎么解决这个问题?你知道吗

enter image description here

import scrapy

class IndeedSpider(scrapy.Spider):
    name = 'indeed'
    allowed_domains = ['indeed.nl']
    start_urls = ['https://www.indeed.nl/vacatures?q=developer&l=']

    def parse(self, response):
        jobs =response.xpath('//div[@class="  row  result" or 
        @class="lastRow  row  result"]')
        for job in jobs:
            jobtitle = job.xpath('h2/a/@title').extract_first()
            company = 
            job.xpath('.//span[@class="company"]/text()').extract_first()

            yield{
                'jobtitle': jobtitle, 
                'company': company}

Tags: 命令行responsenljobsjobextractresultxpath