phantomjs

PhantomJS .click() not working

≯℡__Kan透↙ 提交于 2019-12-04 05:18:13
This code does not work: var page = require('webpage').create(); page.open('http://www.ebay.com/', function() { console.log('Page loaded'); page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js', function() { console.log('jQuery included'); page.render('C:/beforeclick.jpeg'); console.log('Render 1'); page.evaluate(function() { $('.btn-prim').click(); }); page.render('C:/afterclick.jpeg'); console.log('Render 2'); }); }); In fact $('.btn-prim').click() does not work, beforeclick.jpeg and afterclick.jpeg are the same. In browser console $('.btn-prim').click() works fine

Does PhantomJS support ES6 for serving angularjs app to crawlers and bots?

可紊 提交于 2019-12-04 05:10:16
I am trying to use ajax-seo for an Angularjs app to serve html compiled content from a PhantomJS webserver`. But it's not rendering the complete page. It's just giving the following response <html><head></head><body></body></html> I have followed the instructions well but no luck so far. So I'd like to know whether PhantomJS supports ES6 or not, because my app is in ES6. PhantomJS 2.1.1 only supports about 10% of ECMAScript 6, which might not be enough to properly render your page. Here is a slightly more detailed result based on https://kangax.github.io/compat-table/es6/ : Overall coverage:

PNG is not being rendered using PhantomJS with multiple attempts in a loop

蓝咒 提交于 2019-12-04 04:50:15
问题 var page = require('webpage').create(); var filepath = "/home/abc/" + "abc.html"; //create path to charts.html for (i = 0; i < 3; i++) { // make three attempts console.log("hi") page.open(filepath, function(status) { console.log(status); //if(status !== 'success') { //if not success, make another attempt // continue; // } page.render('abc.png'); phantom.exit(); }); } phantom.exit(); running this code like this: $ phantomjs hello.js Q1: I am expecting abc.png to be generated in my home dir.

How to reduce PhantomJS's CPU and memory usage?

狂风中的少年 提交于 2019-12-04 03:47:04
I'm using PhantomJS via Python's webdriver lib. It eats lots of RAM and CPU, and it's an issue because I'd like to run as many instances as it's possible. Some google'ing didn't give me anything helpful. So I'll ask directly: Does the size matter? If I set driver.set_window_size(1280, 1024), will it eat more memory than 1024x768? Is there any option in the source code which can be turned off without real issues and which lead to significant memory usage reduce? Yes I still need images and CSS and JS loading and applying, but I can get rid of some other features... For example, I can turn off

PhantomJS - 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive

穿精又带淫゛_ 提交于 2019-12-04 03:22:44
问题 I'm trying to change the value of a input with PHP webdriver and PhantomJS. When I run a simple $driver->executeScript("document.getElementById('changeme').value='".$newvalue."' ;", array()); I get the following error Refused to evaluate a string as JavaScript because unsafe-eval is not an allowed source of script in the following Content Security Policy directive I've got the following command line options set --ignore-ssl-errors=true --web-security=false --ssl-protocol=any Any suggestions?

How can I use google web fonts with phantomjs

主宰稳场 提交于 2019-12-04 03:03:18
问题 I'm using phantomjs version 1.9.7 which I believe is supposed to support web fonts. I have inserted the font with google web fonts however it is just displaying my fallback font when I automate a screengrab. The webfont is displaying fine in all my browsers. Are there any workarounds for this? 回答1: I have struggled with this issue for several hours. Well, there is a simple reason for this controversy: user-agent ! Some services such as Google Fonts are returning different CSS content based on

PhantomJS not rendering screenshots with webfonts?

心不动则不痛 提交于 2019-12-04 03:01:50
问题 So I have been looking around and can't seem to find a solution on how to get PhantomJS to actually display webfonts on screenshots, can anyone tell me if there is a way to do this? 回答1: I have been testing and testing for about a week now and finally came up with the answer, know that this might also be a result of me running PhantomJS on a Windows machine. I am currently running PhantomJS v1.9.7 and have found the following solution: Using this in my CSS file: @font-face { font-family:

How do you create a browser profile for Selenium's PhantomJS/GhostDriver?

耗尽温柔 提交于 2019-12-04 02:55:48
问题 Here's how you create a Firefox profile: fp = webdriver.FirefoxProfile() fp.set_preference("browser.download.folderList",2) fp.set_preference("browser.download.dir", download_dir) fp.set_preference("browser.download.manager.showWhenStarting",False) fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/csv") How do you do it with PhantomJS (GhostDriver)? 回答1: The closest you can get with phantomjs is to use the driver capabilities: DesiredCapabilities caps = DesiredCapabilities

Run/Execute CasperJS script by clicking a button on webpage

两盒软妹~` 提交于 2019-12-04 01:52:49
问题 I have a casperJS script which returns a JSON when run on commandline. I want to have an arrangement such that 1) I create a webpage 2) On clicking a button on the webpage the casperJS scripts gets executed at the server side and post/return the result back to the webpage. How can i do the same. EDIT: I am invoking an AJAX process written in php on clicking the buttom. The php script contains echo exec('casperjs sample.js'); It returned nothing but on checking the webserver error log I got

Using poltergeist with a proxy?

一世执手 提交于 2019-12-04 01:43:01
问题 I'm using PhantomJS and poltergeist to emulate a browser, however I'm not sure how to specify a proxy to use in the code: require 'capybara' require 'capybara/dsl' require 'capybara/poltergeist' task :experiment => :environment do Capybara.run_server = false Capybara.current_driver = :poltergeist Capybara.app_host = "http://something.com" include Capybara::DSL # set_proxy('12.13.14.15', '4521') visit('posts') page.include?('foo') end Also, for some reason, i get undefined method page when