将Scrapy数据添加到不带标题行的csv
我们有一个本地网站,可以跟踪使用特定许可证的人数。我创建了一个刮刀,每小时运行一次。我遇到的唯一问题是创建如下所示的数据。
active_users,date,time
35,22/03/2022,11:38:30.397745
active_users,date,time
36,22/03/2022,11:44:04.753589
我发现的问题是,每次运行 scrapy scrapy users
时,它都会添加该标头。我知道 scrapy 有 CsvItemExporter()
可以删除标头,但我不太确定如何使用它。
我只需要输出 csv 看起来像
active_users,date,time
35,22/03/2022,11:38:30.397745
36,22/03/2022,11:44:04.753589
We have a local website that tracks the number of people using a certain license. I have create a scraper with that should run every hour. The only issue I have it's creating data that looks like this.
active_users,date,time
35,22/03/2022,11:38:30.397745
active_users,date,time
36,22/03/2022,11:44:04.753589
the issue I find is that every time scrapy crawl users
is ran it adds that header. I know scrapy has CsvItemExporter()
that can remove the header but I'm not too sure how to use it.
I just need the output csv to look like
active_users,date,time
35,22/03/2022,11:38:30.397745
36,22/03/2022,11:44:04.753589
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 scrapy 2.4 及更高版本,您可以在定义 FEED 时直接更改此设置,如下所示。
这将附加到文件的内容,而不是每次添加新的标头。
If you are using scrapy version 2.4 and above you can directly change this setting when defining the FEED such as below.
This will append to the contents of the file instead of adding a new header each time.