Can Scrapy set different parse function for every start_urls?
This is the piece of pseudo-code:
start_urls = [
"http://111sssssssss.com",
"http://222sssssssssssss.com",
"http://333sssssssssss.com",
"http://444sssssssss.com",
]
def parse_1():
'''some code, this function will crawl http://111sssssssss.com'''
def parse_2():
'''some code, this function will crawl http://222sssssssssssss.com'''
Is there any way to do that?
You can override / implement the parse_start_url
function and there call parse_1
or parse_2
when the response.url
meets your criteria (in this case it is the right URL).
def parse_start_url(response):
if response.url == 'http://111sssssssss.com':
parse_1(response)
if response.url == 'http://222sssssssssssss.com':
parse_2(response)
For more information about parse_start_url()
read the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With