【问题标题】:Scrapy Is not Crawling AnythingScrapy 不会抓取任何东西
【发布时间】:2019-11-16 14:15:24
【问题描述】:

Scrapy Crawler 在终端中运行代码时正在爬行,但是当我在编辑器中运行代码时它不起作用。我的代码是:

from scrapy import Spider
from selenium import webdriver
from scrapy.selector import Selector
from scrapy.http import Request
class BooksSpider(Spider):
    name = 'books'
    allowed_domains = ['books.toscrape.com']


def start_request(self, response):
    self.driver=webdriver.Chrome(r'C:\Users\Night-Watch\Desktop\chromedriver.exe')
    self.driver.get('http://books.toscrape.com')
    sel=Selector(text=self.driver.page_source)


    books=sel.xpath('//h3/a/@href').extract()
    print(books)

【问题讨论】:

标签: python selenium scrapy


【解决方案1】:
  1. 您确定要使用 Selenium 抓取简单的测试站点吗?开销很大。
  2. 您能否提供错误文本和堆栈跟踪以了解情况的全貌。

【讨论】:

  • 我认为这应该是一个评论。
  • 是的,在这里评论会更好。
  • @MichaelSavchenko 上传图片
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-14
  • 1970-01-01
  • 1970-01-01
  • 2018-08-20
相关资源
最近更新 更多