phantomjs

How to use fillSelectors in casperjs

泪湿孤枕 提交于 2019-12-25 05:48:13
问题 I need to get some content from the page, but if I use fillSelectors() the content is not load. Maybe i need use evaluate() , but i dont undestend where and how. var casper = require('casper').create() casper.start('http://console.matomycontentnetwork.com/', function() { this.fillSelectors('form#login-form', { 'input[name="username"]': 'jpost', 'input[name="password"]': 'matomy123' }, true); this.clickLabel("Sign In", 'button'); }); casper.then(function() { var start_date = '09/01/2015'; var

Is it possible to use 'fs' (filesystem) module inside page executed by PhantomJS?

混江龙づ霸主 提交于 2019-12-25 05:36:08
问题 I want to have access to filesystem on a page that is rendering by PhantomJS headless browser. I catch an error when JS code is trying to interact with filesystem var fs = require('fs'); ... ReferenceError: Can't find variable: require Is there some hack/plugin to PhantomJS that allows to do that? P.S. I'm using headless tests runner based on PhantomJS (teaspoon) and I want to store some data from tests on filesystem. 来源: https://stackoverflow.com/questions/30779915/is-it-possible-to-use-fs

how to fetch / grab polymer spa webpage by using python with headless server and no GUI

自作多情 提交于 2019-12-25 05:04:47
问题 I'm trying to grab the content of the following url: https://docs-05-dot-polymer-project.appspot.com/0.5/articles/demos/spa/final.html My goal is to grab the content (source code) of the webpage as seen by the visitor, so after it has rendered all javascripts etc. To do so I used the example mentioned here:http://techstonia.com/scraping-with-phantomjs-and-python.html That example works on my server. But the challenge is to also have it work for polymer based SPA sites like the one mentioned.

page.open() function doesn't work properly for some URLs

限于喜欢 提交于 2019-12-25 04:53:19
问题 I am new in node. I have written a code using Node and Phantom to scrape a website. My code is working for google.com but not working for facebook because it is internally making an ajax request to other files to get the data. var phantom = require('phantom'); phantom.create(function(ph) { return ph.createPage(function(page) { return page.open("https://facebook.com/", function(status) { if(status !== 'success'){ console.log('Unable to load the url!'); ph.exit(); } else { setTimeout(function()

Casperjs and waitForUrl() to wait for next page

倾然丶 夕夏残阳落幕 提交于 2019-12-25 04:46:51
问题 I'd like to use the waitForUrl() function from http://docs.casperjs.org/en/latest/modules/casper.html#waitforurl . After a login form was send casperjs should wait for the next page is loaded. In the code below you see the "Second variant" that's the way I try to code this and you also see the occuring error message. The "First variant" is working so the dashboard.png is captured. Can someone explain what is wrong with the "Second variant"? // ... // Type and send login Form casper.then

PhantomJs automation requires unsafe-eval to work

北城以北 提交于 2019-12-25 04:24:55
问题 I'm using Selenium Java and PhantomJs to automate a GUI that is written in Scala and running on the Play framework. Recently, the PhantomJs driver fails to run. I've traced it down to the security headers. In the application.conf , if I have the following: play.filters.headers.contentSecurityPolicy="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';" Then the PhantomJs test fails on interacting with any form elements (even something as simple as finding a

Casper.js/Phantom.js not submitting data

匆匆过客 提交于 2019-12-25 04:22:23
问题 I'm using Casper.js to automate submitting a form. The form's onSubmit method returns false and runs some javascript (onclick callback) before sending the data, so I have to use clickLabel , instead of fill . The data is prepopulated, I just have to click the Submit button. When I use Casper to do clickLabel('Submit') , the data isn't submitted. What am I doing wrong? Edit - here's the markup of the label: <a class="green_btn white font_18 arrow_btn_pad rad_5" onclick="$.shactivity

CasperJS - Scraper not navigating to the next page

最后都变了- 提交于 2019-12-25 03:59:16
问题 The following code is a simple scraper written in CasperJS. var casper = require('casper').create(); var url = casper.cli.get(0); var page1 = casper.cli.get(1); var page2 = casper.cli.get(2); //console.log(page2); var proxy = casper.cli.get(3); //alert(page1); var exp = /[-a-zA-Z0-9@:%_\+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_\+.~#?&//=]*)?/gi; var regex = new RegExp(exp); var baseUrl = url; //console.log(baseUrl); var nextBtn = "a.navigation-button.next"; var allLinks = []; casper

The element is clicked, but Page is not reloaded accordingly

人盡茶涼 提交于 2019-12-25 03:52:40
问题 Using phantom JS, I am trying to click a <li> element(target_element) and render the page which loads after it. The element is clicked successfully. But, on rendering, the refreshed page is not seen in the output. I have given enough wait item. The code is: page.open(address, function (status) { if (status !== 'success') { console.log('Unable to load the address!'); phantom.exit(); } else { window.setTimeout(function () { page.evaluate(function() { document.getElementById('custom_filters')

node-phantom handle hyperlink of iframe fail

倖福魔咒の 提交于 2019-12-25 03:48:16
问题 Recently, i integrate node and phantomjs by phantomjs-node. I opened page that has iframe element, i can get the hyperlink element of iframe, but failed when i execute click on it. Do you have a way? Anyone can help me? example: page.open(url); ... page.evaluate(function(res){ var childDoc = $(window.frames["iframe"].document), submit = childDoc.find("[id='btnSave']"), cf = submit.text();//succeed return text submit.click()//failed return cf; },function(res){ console.log("result="+res);/