phantomjs

Open link in PhantomJS synchronously

夙愿已清 提交于 2019-11-30 09:51:35
问题 I want to know is there any way to click link (open link) on PhantomJS synchronously. First page must be opened first, then click link on the first page to go to second page. Here is my approach using setTimeout: var page = require('webpage').create(); var url = "http://domain.tld/index.html"; page.open(url, function (status) { page.render("1-home.png"); page.evaluate(function() { // search for element and click it to redirect document.getElementById("RetailUser").click(); }); // I use

cntlm proxy with phantomjs

久未见 提交于 2019-11-30 09:50:39
I'm trying to use the cntlm proxy on my windows machine to talk to a local web application on IIS that uses Windows Authentication from PhantomJS. To create the proxy, I'm doing: cntlm -v -u username@domain -p password -l 1456 localhost:80 My app lives at localhost/myapp To test whether or not this works, I try to browse to localhost:1456/myapp but I always get an auth challenge and no sensible username/password combination seems to work. Any thoughts on why this setup might not be working as expected? When I hit the proxied endpoint in a browser, this is the output from cntlm: http://pastebin

grunt-contrib-jasmine and PhantomJS security

拥有回忆 提交于 2019-11-30 09:25:49
I'm getting an error XMLHttpRequest cannot load https://my-api.domain.com . Origin file:// is not allowed by Access-Control-Allow-Origin. when I try to run some async unit tests that query an API through grunt-contrib-jasmine, which in turn using PhantomJS. I see that the command line version of PhantomJS does have a 'web-security' options. Can I control how grunt-contrib-jasmine uses PhantomJS to include this option and disable the cross-domain security? You can pass options to phantomjs similarly to how you would on the command line, e.g. The following options may help, but more can be found

How to list loaded resources with Selenium/PhantomJS?

微笑、不失礼 提交于 2019-11-30 09:16:44
I want to load a webpage and list all loaded resources (javascript/images/css) for that page. I use this code to load the page: from selenium import webdriver driver = webdriver.PhantomJS() driver.get('http://example.com') The code above works perfectly and I can do some processing to the HTML page. The question is, how do I list all of the resources loaded by that page? I want something like this: ['http://example.com/img/logo.png', 'http://example.com/css/style.css', 'http://example.com/js/jquery.js', 'http://www.google-analytics.com/ga.js'] I also open to other solution, like using PySide

PhantomJS keeping cache

三世轮回 提交于 2019-11-30 09:02:52
I am using phantom js to test accessing a webpage, this runs approximatley 350 times in the space of about half an hour. I am then running webalizer against the server to test page accesses. My phantom js clients are inside 1 instance of phantom js so it basically works in the sense that once one client has opened the web page kick off the next client, all with individual IP addresses and MAC addresses throughout. However what I am finding in webalizer is that while I get 350 hits to the server I am only getting 1 hit per instance of phantomjs I run on some css files and others. So I have come

iText is deforming/misspelling Unicode characters in pdf

主宰稳场 提交于 2019-11-30 08:49:05
问题 I am trying to generate a pdf using iText v2.1.5 which basically contains Unicode characters, Ariel is the font being used for the same. Now the problem is that some of the characters like the "Hindi" and "Gujarati" characters are having issues being generated properly. Please take a look at the below screenshot to understand the issue better. Both the highlighted fonts in the Graph and Table use the same fonts, but the font in the table are not proper for hindi and gujarti characters. The

Passing a variable to PhantomJS via exec

假装没事ソ 提交于 2019-11-30 08:30:11
问题 I'm getting started with Grunt and wanting to pass a variable to a PhantomJS script I'm running via exec. What I want to be able to do is pass a url in for the script to take the screen capture from. Any help would be greatly appreciated, thanks! Darren Grunt script exec('phantomjs screenshot.js', function (error, stdout, stderr) { // Handle output } ); screenshot.js var page = require('webpage').create(); page.open('http://google.com', function () { page.render('google.png'); phantom.exit();

Set element height in PhantomJS

心已入冬 提交于 2019-11-30 08:20:47
问题 How do I set element height while testing in PhantomJS? I'm testing on Karma using Jasmine framework and running on PhantomJS headless browser. I'm trying to test an AngularJS directive concerned with "infinite scrolling" (automated loading of items when user scrolls near to the bottom of the container element). I'm not using jQuery, nor do I wish to (unless there's no other way). I'm using .clientHeight , .scrollTop , and .scrollHeight properties. My directive works as expected, at least in

Browser-based client-side scraping

ⅰ亾dé卋堺 提交于 2019-11-30 08:18:59
I wonder if its possible to scrape an external (cross-domain) page through the user's IP? For a shopping comparison site, I need to scrape pages of an e-com site but several requests from the server would get me banned, so I'm looking for ways to do client-side scraping — that is, request pages from the user's IP and send to server for processing. Johann Bauer No, you won't be able to use the browser of your clients to scrape content from other websites using JavaScript because of a security measure called Same-origin policy . There should be no way to circumvent this policy and that's for a

PhantomJS: injecting a script before any other scripts run

你说的曾经没有我的故事 提交于 2019-11-30 08:04:28
Using PhantomJS, I'd like to inject some JS as if there was an extra <script> tag before any other <script> tags. This is because the scripts on the page use some functions that PhantomJS does not have, namely Function.prototype.bind and window.webkitRequestAnimationFrame . I have a JS file with custom implementations of the two and I'd like PhantomJS to use them when running the scripts on the page. The difficulty is that if I do page.injectJs before page.open, the script is injected into an empty page and is not carried over to the page being opened. Alternatively, if I do page.injectJs