栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

使用Python Selenium自动连接我的Gmail帐户

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

使用Python Selenium自动连接我的Gmail帐户

尝试更改网址。使用

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"


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/401446.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号