from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from scrapy import signals
class GeturlSpider(scrapy.Spider):
name = 'geturl'
#allowed_domains = ['https://map.lianjia.com/map/310000/ESF']
start_urls = ['https://map.lianjia.com/map/310000/ESF/']
def __init__(self):
path='E:/python/chromedriver_win32/chromedriver.exe'
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
self.driver = webdriver.Chrome(executable_path=path, chrome_options=chrome_options)
super().__init__()
def parse(self, response):
time.sleep(3)
driver = self.driver
driver.get("https://map.lianjia.com/map/310000/ESF/")
driver.save_screenshot('1-1.jpg')
目前由于phantomjs已经不维护了,而新版的Chrome(59+)推出了Headless模式