在网站中搜索产品 - Scrapy

Searching a product in a website - Scrapy

我有一个网站,其中有一个搜索栏。我希望用户输入一个字符串,我想在网站中搜索该特定字符串并抓取结果页面。一个是我想出这样做是进行搜索 url 并连接用户输入的任何内容,因此 url 是 “https://www.czone.com.pk/search.aspx?kw=" 如果用户输入“ssd”,我会将其连接起来,这应该是我的开始 url。这就是我在这里尝试做的,但它不起作用。


class ProductsSpider(scrapy.Spider):
    name="gaming"
    start_urls = ["https://www.czone.com.pk/search.aspx?kw="]
    product = input("Enter the item you are looking for")
    start_urls = start_urls[0] + product

    def parse(self,response):
       pass

但是爬虫在执行时报错 [scrapy.core.engine]错误:获取启动请求时出错 ValueError:请求中缺少方案 url:h

是我在蜘蛛中做错了什么,还是我解决问题的整个方法都是错误的?

尝试:

import scrapy

class ProductsSpider(scrapy.Spider):
    name="gaming"
    #url = "https://www.czone.com.pk/search.aspx?kw="
    product = input("Enter the item you are looking for")
    
    def start_requests(self):
        yield scrapy.Request(
            url = f'https://www.czone.com.pk/search.aspx?kw={product}',
            callback = self.parse
        )
    def parse(self,response):
       pass