草庐IT

phantomjs-prebuilt

全部标签

python - 使用 Webdriver 和 PhantomJS 记录 HTTP 流量

如何使用PhantomJS通过Webdriver记录页面加载的所有HTTP请求和响应?我正在使用python,我的super简单测试脚本如下所示:fromseleniumimportwebdriverdriver=webdriver.PhantomJS()driver.get('http://www.golem.de')我已经在PhantomJS中找到了这些功能:page.onResourceRequested=function(request){console.log('Request'+JSON.stringify(request,undefined,4));};但我不知道如何将其

python - 在 Selenium [Python] 中使用 PhantomJS 进行透明截图?

当我使用PhantomJS作为Selenium中的网络驱动程序截取屏幕截图时,我得到的只是透明背景。任何线索为什么?它适用于Google.com之类的页面,但不适用于我想要的kahoot.it。它也适用于我在Firefox中需要的所有其他东西,但不适用于PhantomJS。fromseleniumimportwebdriverfromselenium.webdriver.common.keysimportKeysfromselenium.webdriver.common.desired_capabilitiesimportDesiredCapabilitiesimporttimedca

python - 如何使用 Selenium/PhantomJS 列出加载的资源?

我想加载一个网页并列出该页面的所有加载资源(javascript/images/css)。我使用此代码加载页面:fromseleniumimportwebdriverdriver=webdriver.PhantomJS()driver.get('http://example.com')上面的代码运行良好,我可以对HTML页面进行一些处理。问题是,如何列出该页面加载的所有资源?我想要这样的东西:['http://example.com/img/logo.png','http://example.com/css/style.css','http://example.com/js/jquer

Python - Selenium PhantomJS - JSON 错误

我有一个使用Selenium和PhantomJS的小型测试python脚本。Python版本是2.7,PhantomJS是1.9.2。我稍后计划将其与BeautifulSoup一起用于访问金融网站。我的python脚本如下所示-fromseleniumimportwebdriverphantomJSPath="C:\myworkingdir\\Lib\phantomjs.exe"browser=webdriver.PhantomJS(executable_path=phantomJSPath)执行后出现以下错误-运行中的文件“C:\myworkingdir\Test.py”,第32行b

python - 使用 PhantomJS 运行 Selenium Webdriver 时出现 InvalidElementStateException

我正在运行在Firefox中运行正常的selenium测试,但在使用PhantomJS时出现错误。这是我的python代码:driver.find_element_by_link_text("AddProvince").click()driver.find_element_by_id("id_name").clear()driver.find_element_by_id("id_name").send_keys("Frosinone")driver.find_element_by_id("id_code").clear()driver.find_element_by_id("id_co

python - PhantomJS 1.8 在 python 上使用 Selenium。如何屏蔽图片?

有没有办法在Selenium上配置PhantomJSwebdriver不加载图像?我知道如果我直接使用phantomjs,我可以用--load-images=no启动它,它不会加载图像,但我如何通过Selenium和Python配置它?更新尝试了以下操作:args={'desired_capabilities':{'loadImages':False}}driver=webdriver.PhantomJS(**args)没有成功... 最佳答案 你为什么不尝试webdriver.PhantomJS(service_args=['--

python - 防止在 Python 驱动的 PhantomJS/Selenium 中下载 CSS/其他资源

我试图通过阻止下载CSS/其他资源来加速Python中的Selenium/PhantomJSwebscraper。我只需要下载imgsrc和alt标签。我找到了这段代码:page.onResourceRequested=function(requestData,request){if((/http:\/\/.+?\.css/gi).test(requestData['url'])||requestData['Content-Type']=='text/css'){console.log('Theurloftherequestismatching.Aborting:'+requestDa

python - 获取 URLError : <urlopen error [Errno 111] Connection refused> in selenium webdriver using python in phantomjs

我在Python中使用SeleniumWebdriver。在headless浏览器(phantomjs)中运行脚本时出现URLError:谁能帮忙解决这个问题? 最佳答案 用谷歌搜索后,它似乎不可预测地发生了,但在我用Selenium/Phantom提出了一些请求之后。如果我使用driver=webdriver.PhantomJS()创建一个新的webdriver,那么我就可以继续发出请求。我建议其他人使用相同的解决方法。 关于python-获取URLError:inseleniumwe

javascript - 如何将html文件的控制台输出带入phantomjs

我正在使用一个文件中的html文件运行qunit测试,而我正在从phantomjs运行该html文件。当我通过浏览器运行html文件时,我在控制台中获得输出,但是当我尝试使用phantomjs运行时,我没有在我调用html文件的另一个js文件中获得控制台输出。我提供两个文件:HTML文件:JUnitreporterforQUnitQUnit.config.reorder=false;QUnit.jUnitDone(function(data){varconsole=window.console;if(console){console.log(data.xml);}});Js文件:var

html - 如何在 node.JS 中使用 phantomJs 将 html 内容呈现为 pdf 文件

如何使用node.js中的phantom.js生成包含一些html内容的pdf文件并将文件和内容呈现给浏览器? 最佳答案 为什么不使用html-pdf使用phantomJS的npm模块?代码示例varfs=require('fs');varpdf=require('html-pdf');varhtml=fs.readFileSync('./test/businesscard.html','utf8');varoptions={format:'Letter'};pdf.create(html,options).toFile('./bu