webdriver

Automating gmail login [During oAuth] gets blocked with user verification

こ雲淡風輕ζ 提交于 2020-01-22 03:01:18
问题 This code works to login to gmail public void login(User user) { WebDriverWait wait = new WebDriverWait(driver, 60); WebElement emailTextBox = wait.until( ExpectedConditions.visibilityOfElementLocated(By.id("identifierId"))); emailTextBox.sendKeys(user.email); WebElement nextButton = wait.until( ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[contains(text(), 'Next')]"))); nextButton.click(); WebElement passwordTextBox = wait.until( ExpectedConditions.visibilityOfElementLocated

How to expand the reviews and scrape the text clicking for the next page using Selenium and Python

落花浮王杯 提交于 2020-01-22 02:32:07
问题 I wish to scrape reviews from this url: https://seedly.sg/reviews/p2p-lending/funding-societies by using selenium. For my '''Automation of getting to the next page''' code (clicking for the next page),ElementClickInterceptedException and NoSuchElementException have continuously been thrown even though the element exist, the xpath is correct and it has even run successfully for several times. I added sleeps intentionally but this is still not working. May I know how should I solve this? Thanks

How to rotate various user agents using selenium python on each request

徘徊边缘 提交于 2020-01-22 02:29:10
问题 I want to make 10 requests to https://www.google.com/ but with random user agents using selenium and python. I've a loop and inside that loop I'm making 10 requests with random user agents (using fake-user agent). The main problem is for every request web driver is opening a new instance of google chrome and I want to do this in one single instance but with different user agents. How can I make this possible ? 1 google chrome instance and 10 requests with 10 random user agents. Here is my

selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 80

一世执手 提交于 2020-01-22 02:14:09
问题 when i go to command prompt and type chromedriver -v: ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614}) but when i try to run this code : from selenium import webdriver class InstaBot: def __init__(self): self.driver=webdriver.Chrome() self.driver.get("www.instagram.com") InstaBot() it gives me error like this: raise exception_class(message, screen, stacktrace) selenium.common.exceptions.SessionNotCreatedException: Message: session not created:

【WebDriver API】python之selenium下载文件

大兔子大兔子 提交于 2020-01-22 00:57:51
WebDriver允许我们设置默认的文件下载路径,也就是说,文件会自动下载并且存放到设置的目录中,下面以FireFox浏览器为例,执行文件的下载。 案例1 from selenium import webdriver from time import sleep import os fp = webdriver.FirefoxProfile() fp.set_preference("browser.download.folderList", 2) fp.set_preference("browser.download.manager.showWhenStarting", False) fp.set_preference("browser.download.dir", os.getcwd()) fp.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octer-stream") #下载文件的类型 driver = webdriver.Firefox(firefox_profile=fp) driver.implicitly_wait(10) driver.maximize_window() driver.get('https://pypi.org/project/selenium/')

Session not created Selenium/webdriver when using Safari 12

陌路散爱 提交于 2020-01-22 00:03:26
问题 Since upgrading to Safari 12, my automated scripts are now getting this error: SessionNotCreatedError: Request body does not contain required parameter 'capabilities'. (The error does not occur for other browsers). I'm using the javascript webdriver bindings and, when I build webdriver, I use the withCapability key value pairs: var capabs = { 'browserName' : 'Safari', 'version' : '12.0' } browserUnderTest = new webdriver.Builder(). withCapabilities(capabs) .forBrowser('safari') .build(); I

Session not created Selenium/webdriver when using Safari 12

左心房为你撑大大i 提交于 2020-01-22 00:02:16
问题 Since upgrading to Safari 12, my automated scripts are now getting this error: SessionNotCreatedError: Request body does not contain required parameter 'capabilities'. (The error does not occur for other browsers). I'm using the javascript webdriver bindings and, when I build webdriver, I use the withCapability key value pairs: var capabs = { 'browserName' : 'Safari', 'version' : '12.0' } browserUnderTest = new webdriver.Builder(). withCapabilities(capabs) .forBrowser('safari') .build(); I

Session not created Selenium/webdriver when using Safari 12

百般思念 提交于 2020-01-22 00:01:41
问题 Since upgrading to Safari 12, my automated scripts are now getting this error: SessionNotCreatedError: Request body does not contain required parameter 'capabilities'. (The error does not occur for other browsers). I'm using the javascript webdriver bindings and, when I build webdriver, I use the withCapability key value pairs: var capabs = { 'browserName' : 'Safari', 'version' : '12.0' } browserUnderTest = new webdriver.Builder(). withCapabilities(capabs) .forBrowser('safari') .build(); I

自动查成绩脚本

﹥>﹥吖頭↗ 提交于 2020-01-21 23:56:41
懒惰是第一生产力! 前些天嫌每次查成绩都要输账号密码登陆然后点点点,所以写了这个自动化脚本。 由于用了轮子,所以几乎没有任何难度。。。 直接贴代码: #!/usr/bin/python3.7 # -*- coding: utf-8 -*- # @Time : 2020/1/12 18:10 # @Author : SystemDefenser # @Email : mrwx1116@163.com # @Software: PyCharm from selenium import webdriver from selenium . webdriver . common . action_chains import ActionChains # 鼠标操作 from selenium . webdriver . chrome . options import Options # 配置参数 import time username = input ( "输入学号:" ) password = input ( "输入密码:" ) # 创建一个配置对象 chromeOption = Options ( ) # 禁止加载图片 # noImages = { # 'profile.default_content_setting_values' : { # 'images' : 2 # } # }

LouGou小爬虫

懵懂的女人 提交于 2020-01-21 23:42:31
1 # _author: Jolly 2 # date: 2019/9/8 3 4 from selenium import webdriver 5 from selenium.webdriver.support.ui import WebDriverWait 6 from selenium.webdriver.support import expected_conditions as EC 7 from selenium.webdriver.common.by import By 8 from lxml import etree 9 import time 10 import csv 11 12 class Lagouspider(object): 13 def __init__(self, writer_info): 14 self.writer_info = writer_info 15 self.list_page_url = 'https://www.lagou.com/jobs/list_python?labelWords=&fromSearch=true&suginput=' 16 self.driver_path = r'D:\xuexiruanjian\chromedriver\chromedriver.exe' 17 self.driver =