>  Q&A  >  본문

网页爬虫 - Python小白用Scrapy爬虫返回的是空元素,请问各位大神哪里出了问题?

用scrapy爬了图书馆书籍的书名和评论,用Chrome的检查拔下来的Xpath,但是运行爬虫返回的是空元素,请问各位哪里出了问题,谢谢大家。
截图:

附上我的Scrapy源码,请大家多指教,谢谢!

from scrapy import Spider
from scrapy.selector import Selector
from CommentCrawl.items import CommentcrawlItem

class commentcrawl(Spider):
    name = "commentcrawl"
    allowed_domains = ["http://opac.lib.bnu.edu.cn:8080"]
    start_urls = [
        "http://opac.lib.bnu.edu.cn:8080/F/S9Q2QIQV5D9R9HBHPI2KNN8JH11TRIRSIEPKYQLTAQQ17LA6B6-16834?func=full-set-set&set_number=010408&set_entry=000001&format=999",
    ]
    def parse(self,response):
        item = CommentcrawlItem()
        item['name'] = Selector(response).xpath('//*[@id="details2"]/table/tbody/tr[1]/td[2]/a/text()').extract()
        item['comment'] = Selector(response).xpath('//*[@id="localreview"]/text()').extract()
        yield item
迷茫迷茫2740일 전767

모든 응답(3)나는 대답할 것이다

  • 黄舟

    黄舟2017-04-18 10:22:37

    해당 페이지에 접속하려면 로그인이 필요하며 로그인 작업이 부족합니다.

    회신하다
    0
  • PHP中文网

    PHP中文网2017-04-18 10:22:37

    로그인으로 인해 페이지가 차단되었습니다.

    회신하다
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:22:37

    실제로 얻은 콘텐츠를 인쇄하거나 저장하여 내용을 확인하세요. 반환된 콘텐츠가 Xpath와 일치하지 않는 것으로 추정되므로 로그인이 필요합니다.

    회신하다
    0
  • 취소회신하다