1
任何人都可以向我解释为什么下面的代码没有找到任何链接?Scrapy SgmlLinkExtractor可以在允许中使用查询参数吗?
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import HtmlXPathSelector
from scrapy.item import Item
class CoursesSpider(CrawlSpider):
name = "courses"
allowed_domains = ["test.com"]
start_urls = [
"http://golfpiste.com/kentat/?p=seuralista"
]
rules = (
Rule(SgmlLinkExtractor(allow=r"kentat/esittely/\?lang=fi",unique=True),callback='parse_item', follow=True),
)
def parse_item(self, response):
self.log('Hi, this is an item page! %s' % response.url)
item = Item()
return item
的问题是,允许= R“kentat/esittely/\?会发现链接跟随,但只要我添加任何查询参数没有找到任何联系,即使kentat/esittely /?LANG =网络链接是肯定存在。
所以我在想,如果SgmlLinkExtractor甚至可以在“允许”的查询参数或者是有什么我做错了吗?
Just to ch eck,你想抓golfpiste.com吗?我只是在浏览器中尝试了下面的URL,并且我没有看到任何明显的链接超出顶部导航栏。 (http://golfpiste.com/kentat/esittely/?lang=fi) – Talvalin
嗯,是的,你是对的,开始的网址是错误的。 :哦,兄弟,我现在不觉得愚蠢。 :-D –
那么这是否意味着代码全部正常工作? – Talvalin