I am not able to follow the link and get back the values.
I tried using the below code I am able to crawl the first link after that it doesnt redirect to the second follow link(function).
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from scrapy.http.request import Request
class ScrapyOrgSpider(BaseSpider):
name = "scrapy"
allowed_domains = ["example.com"]
start_urls = ["http://www.example.com/abcd"]
def parse(self, response):
hxs = HtmlXPathSelector(response)
res1=Request("http://www.example.com/follow", self.a_1)
print res1
def a_1(self, response1):
hxs2 = HtmlXPathSelector(response1)
print hxs2.select("//a[@class='channel-link']").extract()[0]
return response1
You forgot to return your Request in the
parse()
method. Try this code:Log output:
The
parse
function must return the request, not just print it.