在 scrapy 中没有调用回调

Call back not being called in scrapy

我正在试用 scrapy 的 rules/link 提取器。

"restrict_css" 下的 css 是正确的,我可以在 scrapy shell 中使用 response.css 检索 links,但由于某些原因,当我运行 这在蜘蛛 uner 规则和 link 提取器中 parse_product 回调函数未被调用。

rules=(
    Rule(LinkExtractor(restrict_css='a.i-next')),

    Rule(LinkExtractor(restrict_css='div.product-image-wrapper>a'),
         callback='parse_product'),
)

def parse_product(self, response):

    print("Print anything for testing")
    return

谢谢,如有任何帮助,我们将不胜感激。

你的 start_urls 符合 none 的规则。第一条规则用于下一页,第二条规则用于产品,对吗?但您的开始 urls 并未指向产品类别,仅指向着陆页。您需要直接从产品列表页面 url 开始,例如:http://www.orsay.com/de-de/neuheiten/t-shirts/tops.html

或添加其他规则以查找产品列表页面。