So my issue is that I have this CrawlSpider
name = 'recursiveSpider'
allowed_domains = ['industrialnetworking.com']
custom_settings = {
'DUPEFILTER_CLASS' : 'scrapy.dupefilters.BaseDupeFilter',
}
start_urls = [
'https://www.industrialnetworking.com/Manufacturers/Hirschmann'
]
rules = (
Rule(LinkExtractor(restrict_css='div.catCell a::attr(href)'), follow=True),
Rule(LinkExtractor(allow=r"/Manufacturers/Hirschmann*"), callback='parse_new_item')
)
I am trying to hit the product pages of all "Hirshmann" products. I understand that my error is within the 2nd line of the "rules" where I have it allowing anything with Hirschmann*. Although I am unsure how to add a response.css/response.xpath as an argument for allow.
Ideally I would like it so that if the crawler all "div.catCell a:attr(href)" and recursive through them until it detects "response.css('td.cellDesc h2 a::attr(href)')", then it will send that link to my "parse_new_item". If that item is not found then continue with following all links that have "div.catCell a:attr(href)".
Example URL travel path ->
StartURL: https://www.industrialnetworking.com/Manufacturers/Hirschmann
Category: https://www.industrialnetworking.com/Manufacturers/Hirschmann-Rail-Switches
SubCategory: https://www.industrialnetworking.com/Manufacturers/Hirschmann-Switches-Unmanaged
Series: https://www.industrialnetworking.com/Manufacturers/Hirschmann-SPIDER-Family-Rail-Switches
END GOAL ->
Product: https://www.industrialnetworking.com/Manufacturers/Hirschmann-SPIDER-III-Rail-Switches/Hirschmann-SSL20-5TX-Rail-Switch-942-132-001
EDIT - Reason I am targeting the xpath/css path is because the links do not have any obvious pattern that I can use to target the urls.
Thanks everyone!