Jul-25-2018, 10:21 AM
(This post was last modified: Jul-25-2018, 10:21 AM by soothsayerpg.)
I've been trying for almost a week getting the right output for the:
What I want is for the call if there is a 'nofollow', then output 'dofollow'.
Here's my code:

I hope there is someone who can help me on this. And thanks a bunch!
Quote:rel="nofollow"Yes, I've been having success if the a-tag contains the said attribute, but if not, it output either: 'author', bookmark, tag, and other that would be inside 'rel='.
What I want is for the call if there is a 'nofollow', then output 'dofollow'.
Here's my code:
import scrapy class LinkSpider(scrapy.Spider): name = 'TestBOT' base_url = ['example.com'] start_urls = ['I don't know if it's right to publicise the domain name, but if you are familiar with the 'rel' you can test my script on a site you know that has it'] def parse(self, response): linktype = response.css('a::attr(rel)').extract() if linktype != 'nofollow': print('dofollow') else: print('nofollow') for data in response.css('a'): yield { 'Link': data.css('a::attr(href)').extract(), 'Anchor': data.css('a::text').extract(), 'LinkType': data.css('a::attr(rel)').extract(), }Tried xpath but I'm not getting any output than css selector. So, I would appreciate if we stick with .css selector.

I hope there is someone who can help me on this. And thanks a bunch!