Trying to get into https://www.germaniasport.hr/hr/kladjenje/ponuda using casperjs 1.1.4 phantomjs 1.9.8, but can't find what protection is using this website. Tried with ip adress, tried casperjs --ssl-protocol=tlsv1, casperjs --ssl-protocol=any - but no results.
var casper = require('casper').create(
{
pageSettings:
{
loadImages: false,
loadPlugins: false,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36'
},
verbose: false,
logLevel: "debug",
viewportSize : { width: 1920, height: 1080 }
});
casper.start('https://91.213.84.25/hr/kladjenje/ponuda', function() {
this.wait(5000);
this.capture("sh.jpg");
});
You are missing casper.run();at the end of your code, so your code never actually runs...
Related
I'm trying to set the user-agent parameter in Selenium::Chrome, but am not finding the correct way. Has anyone successfully done this?
my $driver = Selenium::Chrome->new(
'user-agent' => 'TEST',
'--user-agent' => 'TEST',
'chromeOptions' => {
prefs => {
'user-agent' => 'TEST',
'--user-agent' => 'TEST',
},
},
extra_capabilities => {
'chromeOptions' => {
prefs => {
'user-agent' => 'TEST',
'--user-agent' => 'TEST',
},
},
'goog:chromeOptions' => {
prefs => {
'download.default_directory' => '/tmp',
'user-agent' => 'TEST',
'--user-agent' => 'TEST'
},
args => [ 'headless' ]
}
}
);
user-agent can be set through the custom_args argument.
To set the user-agent parameter in Selenium::Chrome you can use the following solution:
my $chrome = Selenium::Chrome->new(
custom_args => "--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"
);
PS: Ideally, you should pass a valid user-agent following What is my user agent?
Could you help to solve the problem in API testing by Cypress. When I set the request headers in options section Cypress ignores them and replaces with default ones.
The example of my request:
cy.request({
method: 'POST',
url: 'https://orion.koto.com/api/inn',
Headers: {'sid':'21102xiXXdvsfykg5pj'},
body:'["3211455115"]' ,
})
the request sent by Cypress:
Method: POST URL: https://orion.koto.com/api/inn Headers: {
"Connection": "keep-alive", "user-agent": "Mozilla/5.0 (Windows NT
10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36", "accept": "/",
"accept-encoding": "gzip, deflate", "content-length": 14 } Body:
["3211455115"]
const green_value = "TOTO"
describe('As I have set a green header',()=>{
it('should use this header',()=>{
cy.visit({
method: 'GET',
url: 'https://www.whatismybrowser.com/detect/what-http-headers-is-my-browser-sending',
headers: {
'green': green_value
}
})
})
})
On my side, it work with visit() function. The url used will show you header sent.
Hope this code sample can help you to implement request() function.
I am trying to save all the incoming request and their response into the database.
I am trying to achieve this using express-winston npm package and it is logging response body and request in console. but I wanna save it in database. how can I do this????
var winston = require("winston");
var expressWinston = require("express-winston");
expressWinston.requestWhitelist.push("body");
// expressWinston.responseWhitelist.push("body");
app.use(
expressWinston.logger({
transports: [
new winston.transports.Console({
json: true,
colorize: true
})
]
})
);
expressWinston.responseWhitelist.push("body");
I am getting this log in console.
{"level":"info","message":"HTTP GET /ideas/category/hello","meta":{"res":{"statusCode":200,"body":{"hiiii":"djdjjdjdjdd"}},"req":{"url":"/ideas/category/hello","headers":{"host":"localhost:5000","connection":"keep-alive","upgrade-insecure-requests":"1","user-agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3","accept-encoding":"gzip, deflate, br","accept-language":"en-GB,en;q=0.9,en-US;q=0.8,hi;q=0.7","cookie":"connect.sid=s%3A90PCwDOrv0v9yeSYZq-4I4Quactbcduq.8EpLenv6t1lCPqLcV5R1o1%2FF15p9kEBqrZ82FBHiYJA"},"method":"GET","httpVersion":"1.1","originalUrl":"/ideas/category/hello","query":{}},"responseTime":2}}
After doing some research I got my answer. we can achieve this using winston-sql-transport npm package.see the code given below:
const { Logger } = require('winston');
const { SQLTransport } = require('./../lib/winston-sql-transport');
const logger = new Logger({
transports: [
new SQLTransport({
tableName: 'winston_logs',
})]
});
module.exports = logger;
From within an app, I need to change a proxy to use the GET method to read data and not the OPTIONS method. I have attempted to set the 'method' for the proxy but it does not appear to be taking effect.
var operation = new Ext.data.Operation({
action: 'read',
});
var proxy = new Ext.data.proxy.Ajax({
type: 'ajax',
url: testURL,
method: 'GET',
withCredentials: true
});
proxy.read( operation );
Request Headers from debugger (notice OPTIONS)
OPTIONS /web/datasource?_dc=1476803593106&page=1&start=0&limit=25 HTTP/1.1
Host: <removed>
Connection: keep-alive
Access-Control-Request-Method: GET
Origin: https://rally1.rallydev.com
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.59 Safari/537.36
Access-Control-Request-Headers: x-requested-with
Accept: */*
Referer: <hidden>
Accept-Encoding: gzip, deflate, sdch, br
Accept-Language: en-US,en;q=0.8
The following code works but is not independent of a data store:
var createCORSRequest = function(method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
// Most browsers.
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {
// IE8 & IE9
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
// CORS not supported.
xhr = null;
}
return xhr;
};
var url = testURL;
var method = 'GET';
var xhr = createCORSRequest(method, url);
xhr.onload = function() {
// Success code goes here.
alert( xhr.response );
};
xhr.onerror = function() {
// Error code goes here.
};
xhr.withCredentials = true;
xhr.send();
When a page have meta refresh redirect, I can't get the content of page it was redirected to. Even if I use setTimeout and wait 10 seconds to be sure that the last page is loaded, when I do page.content I get the content of the page before redirect.
Is there is something I can do about it?
Here is my code:
var mainUrl = "http://t.mobitrk.com/?a=t&aff_id=233&tags=df0a14a1-e673-4082-80c1-5283f4daa11cx&o_id=4879&sub_id=34753&sub_param1=xapnt20iix";
function makeRequest(url) {
var page = require('webpage').create();
page.settings.userAgent = "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 5 Build/LMY48I) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.84 Mobile Safari/537.36";
page.onNavigationRequested = function(url, type, willNavigate, main) {
console.log(url);
}
page.open(url, function (status) {
setTimeout(function() {
console.log(page.content);
phantom.exit(0);
}, 10000);
});
}
makeRequest(mainUrl);
The result is:
http://t.mobitrk.com/?a=t&aff_id=233&tags=df0a14a1-e673-4082-80c1-5283f4daa11cx&o_id=4879&sub_id=34753&sub_param1=xapnt20iix
http://app.appsflyer.com/com.groboot.yala?af_prt=fatal2&pid=clicksmob_int&clickid=cB_1448464013_76df1e4d78bf14572c7fe12cafb39f4d_wP&af_siteid=233&advertising_id=&af_sub1=34753
market://details?id=com.groboot.yala&referrer=af_tranid%3DC8KDGS5KXJ5BEQQ%26clickid%3DcB_1448464013_76df1e4d78bf14572c7fe12cafb39f4d_wP%26af_prt%3Dfatal2%26af_siteid%3D233%26pid%3Dclicksmob_int%26af_sub1%3D34753%26advertising_id%3D
<!DOCTYPE html><html><head><meta http-equiv="refresh" content="0;URL=http://app.appsflyer.com/com.groboot.yala?af_prt=fatal2&pid=clicksmob_int&clickid=cB_1448464013_76df1e4d78bf14572c7fe12cafb39f4d_wP&af_siteid=233&advertising_id=&af_sub1=34753"></head><body></body></html>
As you can see, the page.content contains the content of the first link.