,当我在终端中运行代码时,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)
答案 0 :(得分:0)