我是Python的新手,它试图遍历两列的CSV文件;名称和邮政编码:
Name of Company, 1234
最终到达网址应如下所示:
https://www.example.com/result.aspx?what=Name+of+Comapny&where=1234
我这样尝试过:
csvSpider(scrapy.Spider)类: 名称='csv_spider'
def start_requests(self): with open('test.csv') as f: for line in f: if not line.strip(): continue print 'https://www.example.com/result.aspx?what=' + line[0] + '&where=' + line[1] yield Request('https://www.example.com/result.aspx?what=' + line[0] + '&where=' + line[1])
我还在Python文件的开头导入了CSV模块。
不确定我在做什么错-我该怎么做?
谢谢!