Skip to content

Conversation

@RaphaelRheault
Copy link

I needed to access a page using the post action for authentication, so I added a page.post function that calls Phantom's open(url,'post',data,callback). I thought I could share it in case someone else needs it.

Definition :
page.post(url, data[, callback])
url : where to post
data : html encoded string with the body of the request
callback : callback function (optional)

Example code :
var phantom=require('node-phantom');
phantom.create(function(error,ph){
ph.createPage(function(err,page){
var data = "email=[email protected]&pass=my_pass";
page.post('http://domain.com/login',data,function(err,status){
//Do stuff here
});
});
});

Added page.post function to allow a render through a post action.

page.post(url, data[, callback])
	url : where to post
	data : html encoded string with the body of the request 
	callback : callback function (optional)

Example :
var phantom=require('node-phantom');
phantom.create(function(error,ph){
	ph.createPage(function(err,page){
		var data = "[email protected]&pass=my_pass";
		page.post('http://domain.com/login',data,
		function(err,status){
			//Do stuff here
		});
	});
});
Added two cases : pagePost and pagePostWithCallback
Both of them calls Phantom's open(url,'post',data,callback)
Function to test the page.post function.
Actually, it's only a copy of testpageopen.js that calls page.post instead.
@hallas
Copy link

hallas commented Nov 15, 2013

I need this badly. 👍

@michaelklem
Copy link

Need this.

@zhouseahe
Copy link

ph.createPage(function(err,page){
// why does my application stop here , no error reported . what should I do , thanks

@starsinmypockets
Copy link

++please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants