正确的网址,我应该结束了与我的原则是:http://www.lecture-en-ligne.com/towerofgod/168/0/0/1.htmlscrapy LxmlLinkExtractor和相对URL
scrapys获得相对URL以及从源:
<a class="table" href="../../towerofgod/168/0/0/1.html">Lire en ligne</a>
但随后爬不好思考双点斜杠双点是下一个网址的一部分...
我应该转换我从LxmlLinkExtractor与自定义process_value得到的双相对url吗?
scrapy是否正确处理相对URL,我的意思是它的行为?
2014-12-06 17:20:05 + 0100 [togspider] DEBUG:Crawled(200)http://www.lecture-en-ligne.com/manga/towerofgod/>(referer:None)
2014-12-06 17:20:05 + 0100 [togspider] DEBUG:Retrying http://www.lecture-en-ligne.com/../../towerofgod/160/0/0/1 html的>(失败1次):400错误的请求
class TogSpider(CrawlSpider):
name = "togspider"
allowed_domains = ["lecture-en-ligne.com"]
start_urls = ["http://www.lecture-en-ligne.com/manga/towerofgod/"]
rules = (
Rule(LxmlLinkExtractor(allow_domains=allowed_domains,
restrict_xpaths='.//*[@id="page"]/table[2]/tbody/tr[10]/td[2]/a'), callback='parse_chapter'),
)
http://stackoverflow.com/a/19773661/3581357给出了一个答案。实现这种方式,但仍然想知道这是否意图:) def process_links(链接): links = re.sub(r'\。\。\ /','',links) 返回链接 – euri10 2014-12-06 16:43:39