Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
REMitchell
GitHub Repository: REMitchell/python-crawling
Path: blob/master/6-Selenium/phantomjs/examples/postjson.js
164 views
1
// Example using HTTP POST operation
2
3
var page = require('webpage').create(),
4
server = 'http://posttestserver.com/post.php?dump',
5
data = '{"universe": "expanding", "answer": 42}';
6
7
var headers = {
8
"Content-Type": "application/json"
9
}
10
11
page.open(server, 'post', data, headers, function (status) {
12
if (status !== 'success') {
13
console.log('Unable to post!');
14
} else {
15
console.log(page.content);
16
}
17
phantom.exit();
18
});
19
20