20150624
casperjs referrer fake
var fakeReferrer = "http://a.com";
var targetUrl = "http://b.com";
var casper = require('casper').create();
casper.start(fakeReferrer, function () {
this.echo(this.getCurrentUrl());
});
casper.then(function () {
var targetUrl = targetUrl;
this.evaluate(function () {
var link = document.createElement('a'); // make a element
link.setAttribute('href', targetUrl ); // required
link.setAttribute('id', "myTargetUrl"); // add id in element
document.body.appendChild(link); // add a element in document
});
});
casper.then(function () {
this.click('a#myTargetUrl');
});
casper.run(function () {
this.echo(this.getCurrentUrl());
});
//To put in a nutshell....
var casper = require('casper').create();
casper.start().then(function () {
this.page.customHeaders = {
"Referer": fakeReferrer
};
});
casper.thenOpen(targetUrl).run();
피드 구독하기:
글 (Atom)