尝试更改网址。使用
https://accounts.google.com/ServiceLogin?service=mail#identifier代替
http://gmail.com。
确保使用原始电子邮件和密码。并更改
self.driver.find_element_by_name到
self.driver.find_element_by_id每个元素。
您的代码将是:
#!/usr/bin/python# coding: utf8import scrapyimport timefrom selenium import webdriverfrom scrapy.selector import Selectorfrom selenium.webdriver.common.action_chains import ActionChainsfrom scrapy.contrib.spiders import CrawlSpiderfrom scrapy.selector import HtmlXPathSelectorfrom scrapy.contrib.linkextractors.sgml import SgmllinkExtractorfrom scrapy.contrib.spiders import CrawlSpider, Rulefrom scrapy.http import Request, FormRequestfrom scrapy import logfrom scrapy.exceptions import DropItemfrom scrapy import signalsfrom selenium.webdriver.common.by import Byfrom scrapy import signalsfrom scrapy.http import TextResponse from scrapy.xlib.pydispatch import dispatcherfrom selenium import webdriverfrom selenium.webdriver.common.keys import Keysclass googleplay(CrawlSpider): name = "selenium" flag = True def __init__(self): self.driver = webdriver.Firefox() self.driver.get('http://gmail.com') action = webdriver.ActionChains(self.driver) #User name input field identification and data entered usernametext = self.driver.find_element_by_name('Email') usernametext.send_keys("myemail@gmail.com") #put your actual username self.driver.find_element_by_name('signIn').click() #Password input field identification and data entered passwordtext = self.driver.find_element_by_id('Passwd') passwordtext.send_keys("mypassword") #put your actual password self.driver.find_element_by_id('signIn').click() print "----------------------" #key.click() print "----------------------" start_urls = ["https://www.mywebsite.com"] def parse(self, reponse): #Loading the gmail URL print "toto"


