from selenium import webdriver
import scrapy
class chSpider(scrapy.Spider):
name = 'spidypy'
allowed_domains = ['117.145.177.252']
start_urls = ['http://117.145.177.252/login.do?method=enterPdamccx']
def __init__(self):
self.driver = webdriver.Firefox()
def parse(self,response):
self.driver.get('http://117.145.177.252/login.do?method=enterPdamccx')
while True:
try:
next = self.driver.find_element_by_xpath('/html/body/form/div[3]/div/div/a')
url = 'http://117.145.177.252/login.do?method=enterPdamccx'
yield Request(url,callback=self.parse2)
next.click()
except:
break
self.driver.close()
def parse2(self,response):
print('you are here!')
我多次收到以下错误消息:
selenium.common.exceptions.WebDriverException: Message: connection refused
答案 0 :(得分:0)
a具有onclick,因此您可以这样做:
driver.execute_script('doMccx()')