नीचे मेरी मकड़ी कोड,scrapy में परिणामी href के साथ आधार यूआरएल का मेल
class Blurb2Spider(BaseSpider):
name = "blurb2"
allowed_domains = ["www.domain.com"]
def start_requests(self):
yield self.make_requests_from_url("http://www.domain.com/bookstore/new")
def parse(self, response):
hxs = HtmlXPathSelector(response)
urls = hxs.select('//div[@class="bookListingBookTitle"]/a/@href').extract()
for i in urls:
yield Request(urlparse.urljoin('www.domain.com/', i[1:]),callback=self.parse_url)
def parse_url(self, response):
hxs = HtmlXPathSelector(response)
print response,'------->'
यहाँ मैं आधार लिंक के साथ href लिंक गठबंधन करने के लिए कोशिश कर रहा हूँ, लेकिन मैं निम्नलिखित त्रुटि हो रही है, है
exceptions.ValueError: Missing scheme in request url: www.domain.com//bookstore/detail/3271993?alt=Something+I+Had+To+Do
किसी को भी मुझे पता है क्यों मैं इस त्रुटि हो रही है और कैसे href लिंक के साथ आधार यूआरएल में शामिल होने और एक अनुरोध
आपको बहुत धन्यवाद, मुझे जवाब मिला। –
और साथ ही आप मुझे urlparse और urljoin के बीच का अंतर बता सकते हैं क्योंकि उनमें से किसी एक का उपयोग करके भी मैं जवाब प्राप्त कर सकता हूं –
दोनों विधियां urlparse.urlparse और urlparse.urljoin urlparse मॉड्यूल का हिस्सा हैं। यह भी देखें: http://docs.python.org/library/urlparse.html –