我試圖運行通過CLI使用自定義分隔符scrapy出口這樣CSV_DELIMITER參數:Scrapy CLI輸出不工作
scrapy runspider beneficiari_2016.py -o beneficiari_2016.csv -t csv -a CSV_DELIMITER="\n"
出口完美的作品,但是分隔符仍然是默認的逗號( 「」)。
請讓我知道,如果你有任何想法如何修復。謝謝!
的代碼:
import scrapy
from scrapy.item import Item, Field
import urllib.parse
class anmdm(Item):
nume_beneficiar = Field()
class BlogSpider(scrapy.Spider):
name = 'blogspider'
start_urls = ['http://www.anm.ro/sponsorizari/afisare-2016/beneficiari?
page=1']
def parse(self, response):
doctor = anmdm()
doctors = []
for item in response.xpath('//tbody/tr'):
doctor['nume_beneficiar'] =
item.xpath('td[5]//text()').extract_first()
yield doctor
next_page = response.xpath("//ul/li[@class='active']/following-
sibling::li/a/@href").extract_first()
if next_page is not None:
next_page = response.urljoin(next_page)
print(next_page)
yield response.follow(next_page, self.parse)
檢查https://stackoverflow.com/a/28097557/2572383 –