【发布时间】:2015-03-17 17:02:06
【问题描述】:
我的 Scrapy 项目中有以下代码:
rules = [
Rule(LinkExtractor(allow="/uniprot/[OPQ][0-9][A-Z0-9]{3}[0-9]|[A-NR-Z][0-9]([A-Z][A-Z0-9]{2}[0-9]){1,2}"),
callback="parsethings", follow=False),
Rule(LinkExtractor(deny_domains=["help", "category", "citations", "taxonomy","diseases", "locations", "docs", "uniref", "proteomes"])),
Rule(LinkExtractor(deny_domains=[".fasta","?version","?query","?"])),
]
我正在尝试抓取 uniprot (www.uniprot.org) 以获取基因/蛋白质名称和长度。
第一条和最后一条规则可以阻止具有“.fasta”或版本修订号的基因页面的 10,000 个副本,但是,我似乎无法阻止“/help”下的 URL,“ /类别”等。
基本上,我只想抓取 uniprot.org/uniprot 下的 URL。如果我将 allowed_domains 设置为“http://www.uniprot.org/uniprot/”,那么蜘蛛实际上会阻止“www.uniprot.org/uniprot/Q6GZX3”然后死掉。
如何让 scrapy 只抓取 /uniprot 子域中的 URL?
【问题讨论】:
标签: python web-scraping scrapy screen-scraping