IM使用Scrapyto抓取德国论坛:http://www.musikerboard.de/forumScrapy:URL错误,程序增加了不必要的字符(URL代码)
它遵循所有的子论坛,并提取从线程的信息。
问题:在爬行它使我对ultiple threadlinks错误:
2015-09-26 14:01:59 [scrapy] DEBUG: Ignoring response <404 http://www.musiker-board.de/threads/spotify-premium-paket.621224/%0A%09%09>: HTTP status code is not handled or not allowed
的网址,除了这部分/%0A%09%09
它给出了一个404错误罚款。
我不知道为什么程序不断将代码添加到URL的末尾
继承人我的代码:
def urlfunc(value):
value = value.replace("%0A", "")
value = value.replace("%09", "")
return value
class spidermider(CrawlSpider):
name = 'memberspider'
allowed_domains = ["musiker-board.de"]
start_urls = ['http://www.musiker-board.de/forum/'
# 'http://www.musiker-board.de/'
] # urls from which the spider will start crawling
rules = (
Rule(LinkExtractor(allow=(r'forum/\w*',))),
Rule(LinkExtractor(allow=(r'threads/\w+',),deny=(r'threads/\w+/[\W\d]+'),process_value=urlfunc), callback='parse_thread'),
)
是否有人有一个解释为什么它持续发生(和解决?它)
编辑: 更新的代码
它与此合作,谢谢。 – user3811872
而且我了解到'process_value'应用于'url encoding'之前。 –