错误:无法绑定:24:打开的文件太多

2024-04-25 14:06:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我在一个域列表上运行Scrapy,很多页面都遇到了这个错误: Couldn't bind: 24: Too many open files.

我没有在我的linux机器上得到这个错误,但我现在在我的Mac上得到了它。我不确定这是否与在Sierra上运行有关,或者我遗漏了一个糟糕的配置。我检查了ulimit,它返回unlimited,所以我不认为这是事实。在

如果是因为我的蜘蛛,这里是:

class JakeSpider(CrawlSpider):
    name = 'jake'
    allowed_domains = allowedDomains
    start_urls = startUrls
    rules = (
        Rule(LinkExtractor(), callback='parse_page', follow=True),
    )


    def parse_page(self, response):
        page = response.url
        domain = urlparse(page).netloc
        domain = domain.replace('www.','')
        #print(domain, 'is domain and page is', page)
        linksToGet = getHotelUrlsForDomain(domain)
        #if(len(linksToGet) == 0):
        #    print('\n ... links to get was zero \n')
        #print('linksToGet = ', linksToGet)
        links = response.xpath('//a/@href').extract()
        for link in links:
            if link in linksToGet:
                print('\n\n\n   found one! ', link, 'is on', domain, ' and the page is', page,'\n\n\n')
                with open('hotelBacklinks.csv', 'a') as csvfile:
                    writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
                    writer.writerow({'hotelURL':link, 'targetDomain': domain})

编辑:这是其中一个错误的完整行。它并没有导致scrape崩溃,但是像这样的行有很多,所以我想我没有得到像以前那样多的页面。错误线: 2017-09-24 14:21:29 [scrapy.core.scraper] ERROR: Error downloading <GET https://alabamatheatre.com/>: Couldn't bind: 24: Too many open files.

提前感谢您的任何提示。在


Tags: isbindresponsedomain错误pagelink页面