【通过Selenium和python切换到iframe】教程文章相关的互联网学习教程文章

在Python中使用Selenium单击/选择单选按钮【代码】

我试图从3个按钮的列表中进行选择,但找不到选择它们的方法.以下是我正在使用的HTML.<input name="pollQuestion" type="radio" value="SRF"> <font face="arial,sans-serif" size="-1">ChoiceOne</font><br /> <input name="pollQuestion" type="radio" value="COM"><font face="arial,sans-serif" size="-1">ChoiceTwo</font><br /> <input name="pollQuestion" type="radio" value="MOT"><font face="arial,sans-serif" size="-1"...

Python selenium屏幕截图无法获取整页【代码】

我正在尝试创建一个通用的webcrawler,它将访问一个站点并截取屏幕截图.我使用的是Python,Selnium和PhantomJS.问题是屏幕截图没有捕获页面上的所有图像.例如,如果我去你管,它不会捕获主页图像下面的图像. (我没有足够高的代表来发布屏幕截图)我认为这可能与动态内容有关,但我已经尝试了等待函数,例如隐式等待和set_page_load_timeout方法.因为这是一个通用的爬虫我不能等待特定的事件(我想抓取数百个网站). 是否有可能创建一个可以执...

python 利用selenium爬取百度文库的word文章【代码】【图】

今天学习如何使用selenium库来爬取百度文库里面的收费的word文档from selenium import webdriver from selenium.webdriver.common.keys import Keys from pyquery import PyQuery as pq from selenium.webdriver.support.ui import WebDriverWait from selenium import webdriver import time options = webdriver.ChromeOptions() options.add_argument(user-agent="Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76...

python – Selenium-Debugging:元素在点(X,Y)处不可点击【代码】

我试图通过Selenium刮掉这个site. 我想点击“下一页”按钮,为此我这样做:driver.find_element_by_class_name('pagination-r').click()它适用于许多页面但不适用于所有页面,我收到此错误WebDriverException: Message: Element is not clickable at point (918, 13). Other element would receive the click: <div class="linkAuchan"></div>始终为this page 我读了this question 我试过这个driver.implicitly_wait(10) el = driver...

python – Selenium webdriver没有找到Inbox元素【代码】

因为我没有找到解决方案,所以从两个月前就把这个弄得一团糟.我正在使用Firefox驱动程序查找,然后单击名为“收件箱”的超链接但经过详尽的尝试后,Selenium仍无法找到该元素.任何帮助将不胜感激,因为我真的无法找到Selenium webdriver无法找到该元素的原因. 在下面的HTML代码中,我认为可能有一个框架但没有找到;如果有人可以确认在下面的代码中确实没有iframe,那将是值得赞赏的!我的脚本中已经有一个time.sleep(40),以便webdriver有...

python – 消息:错误:轮询更改失败:尝试通过Selenium和FirefoxProfile下载文件时获取资源时出现NetworkError【代码】

我试图在python3上使用selenium和Firefox从url下载文件但是在geckodriver日志文件中给我一个错误:(firefox:13723): Gtk-WARNING **: 11:12:39.178: Theme parsing error: <data>:1:77: Expected ')' in color definition1546945960048 Marionette INFO Listening on port 406011546945960132 Marionette WARN TLS certificate errors will be ignored for this sessionconsole.error: BroadcastService: received...

如何正确等待python-selenium中的框架可用?【代码】

我有一个相当复杂的网页设置我需要测试,包含嵌套框架. 在实际问题中,selenium代码正在加载包含框架的新网页内容,我想切换到该框架.为了避免任何明确的等待,我尝试了以下代码片段:self.driver.switch_to_default_content() WebDriverWait(self.driver, 300). until(EC.frame_to_be_available_and_switch_to_it((By.ID, 'frame1'))) WebDriverWait(self.driver, 300). until(EC.frame_to_be_available_and_switch_to_...

使用Selenium和Beautiful Soup的Python Scraping JavaScript【代码】

我正在尝试使用BS和Selenium抓取一个JavaScript启用页面.到目前为止,我有以下代码.它仍然不会以某种方式检测JavaScript(并返回一个空值).在这种情况下,我试图在底部刮掉Facebook的评论. (Inspect元素将类显示为postText)谢谢您的帮助!from selenium import webdriver from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.keys import Keys import BeautifulSoupbrowser = webdr...

Python Selenium WebDriver拖放【代码】

我无法使用Python WebDriver绑定进行拖放操作.我在Mac OS X上使用谷歌浏览器和Firefox.有一个线程here,其中有人有类似的问题. 我尝试过使用ActionsChains:from selenium import webdriver from selenium.webdriver import ActionChains driver = webdriver.Chrome() actionChains = ActionChains(driver)actionChains.drag_and_drop(source, target).perform()你有没有设法让Python WebDriver拖放工作?解决方法:为了给出更新的答...

如何通过Selenium和Python点击Google搜索结果中的随机链接【代码】

目前使用Selenium Python和这段代码:browser.get('http://www.google.com') search = browser.find_element_by_name('q') search.send_keys("how to search the internet") search.send_keys(Keys.RETURN) # hit return after you enter search text time.sleep(5) # sleep for 5 seconds so you can see the results browser.execute_script("window.scrollTo(0, 873)") time.sleep(2) browser.find_element(By.XPATH, '(//h3)[...

python – 单击按钮后使用Selenium切换到新窗口【代码】

我正在开发一个非常简单的网页项目并且卡住了一点.我正在使用一个网站,在填写表单并单击按钮后,我会在新窗口中显示所需的XML文档数据.但是,我不知道如何访问它,因为我没有给出窗口名称browser = Browser('firefox') browser.visit('http://desiredurl/') form = browser.find_by_id('input') button = browser.find_by_id('send') form.fill(string) button.click()单击按钮会触发ajax请求(doAjaxRequest(“POST”,url,xml);)并打开...

找到reCAPTCHA元素并单击它 – Python Selenium【代码】

我需要协助.有URL:https://www.inipec.gov.it/cerca-pec/-/pecs/companies.我需要点击复选框Captcha: 我的代码看起来像:import os, urllib.request, requests, datetime, time, random, ssl, json, codecs, csv, urllib from urllib.request import Request, urlopen from urllib.request import urlretrieve from datetime import datetime from selenium import webdriver from selenium.webdriver.common.keys import Keys f...

使用python中的selenium webdriver查找具有显式等待的元素【代码】

我试图找到带有链接文本的元素,我正在使用以下代码handle = driver.window_handles #handle for windows driver.switch_to.window(handle[1]) #switching to new window link = wait.until(EC.presence_of_element_located((By.LINK_TEXT, "Followers ")))我正在追踪追溯Traceback (most recent call last): File "<pyshell#28>", line 1, in <module> link = wait.until(EC.presence_of_element_located((By.LINK_TEXT, "Follower...

luminati python+selenium使用方式(白名单和账号密码验证方式)【代码】【图】

一,在Windows下使用 1.官网登录后下载对应的exe代理软件2.下载完成后打开,打开完成后登录127.0.0.1:22999,然后输入用户名和密码进行登录.登录成功后进入到如下界面 3.将本机ip加入到对应的zone白名单 点击对应zone的名称,进入到配置页面 进入到设置页面后可添加白名单ip,包括账号密码验证的账号和密码也是在这里找,而不是登录的账号和密码 4.添加完成后,selenium代码如下: import timefrom selenium.webdriver.chrome.optio...

检查元素是否存在python selenium【代码】

我正在尝试找到元素element=driver.find_element_by_partial_link_text("text")在Python selenium中,元素并不总是存在.是否存在快速行以检查它是否存在并在错误消息不存在时获取NULL或FALSE代替错误消息?解决方法:你可以实现如下的try / except块来检查元素是否存在:from selenium.common.exceptions import NoSuchElementExceptiontry:element=driver.find_element_by_partial_link_text("text") except NoSuchElementException...