많은 수의 URL을 크롤링하고 있으며 'meta name = "robots"content = "noindex"'로 페이지를 구문 분석 할 수 있는지 궁금합니다. 여기에 나열된 거부 규칙을 보면은 거부 규칙이 URL에만 적용되는 것처럼 보입니다. scrapy가 xpath를 무시할 수 있습니까?Scrapy가 noindex를 무시합니다
from scrapy.selector import HtmlXPathSelector
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from wallspider.items import Website
class Spider(CrawlSpider):
name = "browsetest"
allowed_domains = ["www.mydomain.com"]
start_urls = ["http://www.mydomain.com",]
rules = (
Rule(SgmlLinkExtractor(allow=('/browse/')), callback="parse_items", follow= True),
Rule(SgmlLinkExtractor(allow=(),unique=True,deny=('/[1-9]$', '(bti=)[1-9]+(?:\.[1-9]*)?', '(sort_by=)[a-zA-Z]', '(sort_by=)[1-9]+(?:\.[1-9]*)?', '(ic=32_)[1-9]+(?:\.[1-9]*)?', '(ic=60_)[0-9]+(?:\.[0-9]*)?', '(search_sort=)[1-9]+(?:\.[1-9]*)?', 'browse-ng.do\?', '/page/', '/ip/', 'out\+value', 'fn=', 'customer_rating', 'special_offers', 'search_sort=&', 'facet='))),
)
def parse_items(self, response):
hxs = HtmlXPathSelector(response)
sites = hxs.select('//html')
items = []
for site in sites:
item = Website()
item['url'] = response.url
item['canonical'] = site.xpath('//head/link[@rel="canonical"]/@href').extract()
item['robots'] = site.select('//meta[@name="robots"]/@content').extract()
items.append(item)
return items
해당 페이지 검색을 건너 뛰시겠습니까? 그렇다면 메타 로봇을 검색하기 위해 페이지를 검색해야하기 때문에 불가능합니다. – Rolando
죄송합니다. 제 질문에 대한 답을 구했습니다. 'meta name = "robots"content = "noindex"'가 포함 된 URL을 구문 분석하지 않을 수 있습니까? –
xpath를 거부 할 수 있습니까? –