试图读取csv文件,但我得到错误,TypeError: Request url must be str, got list
如何解决,请如何阅读列表任何建议推荐我
import scrapy
from scrapy.http import Request
import pandas as pd
from scrapy_selenium import SeleniumRequest
from io import open
class SampleSpider(scrapy.Spider):
name = 'sample'
with open("category.csv") as file:
start_urls=[line.strip() for line in file]
def start_requests(self):
request=Request(url=self.start_urls,callback=self.parse)
yield request
def parse(self, response):
pass
1条答案
按热度按时间abithluo1#
您需要迭代列表并将每个url作为请求传递。