簡體   English   中英

爬不跟隨鏈接沒有錯誤

[英]scrapy not following links with no error

下面的url都用於提取內容並被遵循,但是提取內容后沒有任何反應。 不知道為什么沒有遵循。

看來沒有錯誤。

在此處輸入圖片說明

您運行兩次“請求作者url”。 第一次刮作者列表。 第二次抓取當前作者的詳細信息。 轉儲Scrapy統計信息(在日志記錄結尾)顯示“ dupefilter / filtered”計數。 這意味着經過抓取的重復過濾網址。 如果刪除“ parse_content”函數並編寫如下代碼,則爬取將起作用:

def parse(self,response):

    if 'tags' in response.meta:
        author = {}
        author['url'] = response.url

        name = response.css(".people-name::text").extract()
        join_date = response.css(".joined-time::text").extract()
        following_no = response.css(".following-number::text").extract()
        followed_no = response.css(".followed-number::text").extract_first()
        first_onsale = response.css(".first-onsale-date::text").extract()
        total_no = response.css(".total-number::text").extract()
        comments = total_no[0]
        onsale = total_no[1]
        columns = total_no[2]
        ebooks = total_no[3]
        essays = total_no[4]

        author['tags'] = response.meta['tags']
        author['name'] = name
        author['join_date'] = join_date
        author['following_no'] = following_no
        author['followed_no'] = followed_no
        author['first_onsale'] = first_onsale
        author['comments'] = comments
        author['onsale'] = onsale
        author['columns'] = columns
        author['ebooks'] = ebooks
        author['essays'] = essays

        yield author

    authors = response.css('section.following-agents ul.bd li.item')
    for author in authors:
        tags = author.css('div.author-tags::text').extract_first()
        url = author.css('a.lnk-avatar::attr(href)').extract_first()
        yield response.follow(url=url, callback=self.parse, meta={'tags': tags})

小心點。 我在測試過程中刪除了一些行。 您需要在HTTP標頭,請求延遲或代理中使用隨機代理。 我運行收集,現在獲得了“ 403 Forbidden”狀態代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM