草庐IT

phantomjs-prebuilt

全部标签

java - Selenium PhantomJS Java - 拒绝评估字符串,因为不允许使用 'unsafe-eval'

我正在玩Selenium和PhantomJS。我正在尝试从网页中绘制所有元素。当我检索某个网页然后尝试获取任何网页元素的位置时,当我在代码中选择网页元素时出现此错误:org.openqa.selenium.WebDriverException:{"errorMessage":"RefusedtoevaluateastringasJavaScriptbecause'unsafe-eval'isnotanallowedsourceofscriptinthefollowingContentSecurityPolicydirective:\"script-srcassets-cdn.githu

python - python proxy-auth 中的 phantomjs + selenium 不工作

我正在尝试使用selenium+phantomjs为网络抓取设置代理。我正在使用python。我在很多地方看到phantomjs中有一个错误,代理验证不起作用。fromselenium.webdriver.common.proxyimport*fromseleniumimportwebdriverfromselenium.webdriver.common.byimportByservice_args=['--proxy=http://fr.proxymesh.com:31280','--proxy-auth=USER:PWD','--proxy-type=http',]driver=w

python - 在 selenium webdriver.PhantomJS 上设置超时

情况我有一个简单的python脚本来获取给定url的HTML源代码:browser=webdriver.PhantomJS()browser.get(url)content=browser.page_source有时,该url指向加载缓慢的外部资源(例如视频文件或非常缓慢的广告内容)的页面。在完成.get(url)请求之前,Webdriver将等待这些资源加载完毕。注意:出于无关原因,我需要使用PhantomJS而不是requests或urllib2问题我想为PhantomJS资源加载设置一个超时时间,这样如果资源加载时间过长,浏览器就会假定它不存在或其他什么。这将允许我根据浏览器加载

python - Proxy+Selenium+PhantomJS 不能改变User-Agent

在phantomjs中使用代理时,它使用默认的python用户代理。运行:Ubuntu14.04上的Python3.5.1service_args=[]ifself.proxy:service_args.extend(['--proxy={}:{}'.format(self.proxy.host,self.proxy.port),'--proxy-type={}'.format(self.proxy.proto),])ifself.proxy.usernameandself.proxy.password:service_args.append('--proxy-auth={}:{}'.

python - Selenium Desired Capabilities - 为 PhantomJS 驱动程序设置 handlesAlerts

我正在使用webdriver试用phantomJS,但在处理javascript警报时遇到了问题。我注意到phantomjs驱动程序desired_capabilities有一个字段'handlesAlerts':False有没有办法将此值设置为true?我已经尝试了明显的方法,但没有任何效果:drv=webdriver.PhantomJS(desired_capabilities={'handlesAlerts':True})printdrv.desired_capabilities{u'browserName':u'phantomjs',u'driverName':u'ghostd

带有 Phantomjs 的 Python Selenium - 单击失败 : ReferenceError: Cant't find variable

我正在使用seleniumwebdriver编写一个python脚本来从网站获取一些数据,并且我正在尝试单击this中的下一步按钮网页。定义按钮的地方:Next在python中使用以下代码URL='http://www.nordpoolspot.com/Market-data1/Elspot/Area-Prices/ALL1/Hourly/'nextId="ctl00_FullRegion_npsGridView_lnkNext"browser=webdriver.PhantomJS('./phantomjs')browser.get(URL)nextBtn=browser.find_

c# - Selenium Webdriver + PhantomJS 保持在大约 :blank for a specific site

我正在尝试将PhantomJS与SeleniumWebdriver一起使用并获得成功,但对于特定网站,我发现它没有导航到URL。我已经用Python和C#试过了。Python代码:dcap=dict(webdriver.DesiredCapabilities.PHANTOMJS)dcap["phantomjs.page.settings.userAgent"]=("Mozilla/5.0(WindowsNT6.2)AppleWebKit/537.36(KHTML,likeGecko)Chrome/31.0.1650.63Safari/537.36")service_args=['--l

c# - Selenium Webdriver + PhantomJS 保持在大约 :blank for a specific site

我正在尝试将PhantomJS与SeleniumWebdriver一起使用并获得成功,但对于特定网站,我发现它没有导航到URL。我已经用Python和C#试过了。Python代码:dcap=dict(webdriver.DesiredCapabilities.PHANTOMJS)dcap["phantomjs.page.settings.userAgent"]=("Mozilla/5.0(WindowsNT6.2)AppleWebKit/537.36(KHTML,likeGecko)Chrome/31.0.1650.63Safari/537.36")service_args=['--l

python - 如何在 python 中使用 phantomjs 和 selenium webdriver 设置窗口大小

我正在尝试使用由pythonwebdriver驱动的phantomjs获取全尺寸浏览器屏幕截图。现在我的屏幕截图测量为927x870,我想重置它。我试过:driver.manage().window().setSize(newDimension(1400,1000))基于thissource,但这是语法错误。我该怎么做? 最佳答案 因为那是Java。Python的文档是here.有一个名为set_window_size的方法,定义为here:driver.set_window_size(1400,1000)进一步阅读:Howtoge

python - 如何在 python 中使用 phantomjs 和 selenium webdriver 设置窗口大小

我正在尝试使用由pythonwebdriver驱动的phantomjs获取全尺寸浏览器屏幕截图。现在我的屏幕截图测量为927x870,我想重置它。我试过:driver.manage().window().setSize(newDimension(1400,1000))基于thissource,但这是语法错误。我该怎么做? 最佳答案 因为那是Java。Python的文档是here.有一个名为set_window_size的方法,定义为here:driver.set_window_size(1400,1000)进一步阅读:Howtoge