How to get data from commandline wappalyzer phantomjs? - phantomjs

I need to get data of url using wappalyzer phantomjs.When i am running phantomjs on commandline then it is working fine.but i need to get the json response on webpage.Can i get the response on webpage using php or some other way.I am not getting full example of it.Please help.

Yes you can do it with php.
$output = shell_exec('/usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs --ssl-protocol=any --ignore-ssl-errors=true driver.js http://example.com');
echo json_decode($output,true);
Note : Change this "/usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/" to directory where you installed the phantomjs.

You need to execute the command:
$output = shell_exec('/usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/phantomjs --ssl-protocol=any --ignore-ssl-errors=true driver.js http://example.com'); echo json_decode($output,true);
Note : Change this "/usr/local/share/phantomjs-1.9.7-linux-x86_64/bin/" to directory where you installed the phantomjs.

Related

How to Use Command Line Parameters by using JMeter?

I'm using Jmeter for testing APIs and I want to parametrize the project's path from the terminal and then I want to use this parameter in JMeter. I set testurl = test.com in basic terminal and i want to get this url by using testurl. The parameter that I've sent via Command Line : ./jmeter -n -t your_script.jmx -l -Jurl=$testurl in homebrew terminal. The parameter that I've used in httpsRequest --> Server name or IP; ${__P(url)}. But when I run my automation in the homebrew terminal, my test scripts are not going to URL that's been defined. Please help me!! Thanks.
From first impression it seems what you are trying should work, but devil is in the detail. I would suggest you try:
Verify if the environment variable is set correctly use export testurl=test.com (removed spaces). Try verify using echo $testurl
Try debug sampler which should help you verify if JMeter is picking up the var correctly: https://www.blazemeter.com/blog/how-debug-your-apache-jmeter-script/
Hope this helps.

PHP Output correct in terminal but not in browser

I just started working with shell_exec in php and stuck at this point.
Below is my php script which runs in terminal correctly but not in browser.
<?php
echo shell_exec("ssh -tq root#192.168.31.5 \"whoami\"");
?>
And output in terminal is
$ php /var/www/html/monitor/ssh.php
root
But in Browser,
Interesting thing is just whoami works like a charm
<?php
echo shell_exec("whoami");
?>
any suggetion is appriciated. Thank you!
EDIT :- USING OB_START() and OB_GET_CONTENT
<?php
ob_start();
echo shell_exec("ssh -tq root#192.168.31.5 \"whoami\"");
$out1 = ob_get_contents();
ob_end_clean();
var_dump($out1);
?>
OUTPUT IN TERMINAL :-
php /var/www/html/monitor/ssh.php
string(6) "root"
OUTPUT IN BROWSER (CHROME) :-
string(0) ""
That's because in CLI you're executing the script as the user from SSH (root in your case) but in browser, the one executing the script is your WebServer (apache/nginx). For you to get root as output in browser you might want to have a look at ob_start ob_get_contents ob_flush functions.

How to generate mocha test case report and show using Jenkins?

I am doing mocha unit testing for my JavaScript functions. I am running mocha in a browser not using Node. I am using require.js to load files.
When I do mocha.run() it shows reports in the browser.
Now I want to make a Jenkins job to display the report.
So how do I generate the report file so that I can provide it to Jenkins?
Running the command:
$ npm install mocha-junit-reporter --save-dev
Will generate an XML file that you can give to Jenkins
Run the command
$ mocha ./test.js --reporter mocha-junit-reporter --reporter-options ./test-results.xml
For docker file use below command
CMD ["mocha", "./test.js" , "--reporter", "mocha-junit-reporter", "--reporter-options","./test-results.xml"]
Both command will do the same.
test-results.xml file be generate in the folder .
I am answering my own question, I have solve this problem by using NGINX server which is open source.
I have added form tag in index.html of mocha and wrote on function on submit form to run mocha suit, this will return you output , parse that output and make file of that according to your need like total success count, failure count etc. and gave to Jenkins.

pyspider phantom is not enabled ;501 Sever Error

I used pyspider to crawl a website, when using PhantomJs, an error occurred as follows:
I've searched for the solutions in https://github.com/binux/pyspider/issues/215,
the author's seemed to solute it, so I tried, but it didn't still. How to solve it?
You need to check if phantomjs is in $PATH
try the following:
phantomjs -v
or try the following and check the output
pyspider phantomjs
it should output
phantomjs fetcher running on port 25555
Otherwise you will need to install phantomjs on your system.

How to download CSV file with poltergeist using Capybara on phantomjs?

For a integration test, I need to download a CSV file using poltergeist driver with Capybara. In selenium(for example firefox/chrom webdriver), I can specify download directory and it works fine. But in poltergeist, is there a way to specify the download directory or any special configuration?. Basically I need to know how download stuff works using poltergeist,Capybara, Phantomjs.
I can read server response header as Hash using ruby but can not read the server response to get the file content.Any clue? or help please.
Finally I solved the download part by simply using CURL inside Ruby code without using any webdriver. The idea is simple, first of all, I submitted the login form via CURL and saved the cookie into my server and then submitted(via CURL) the CVS Export form using the saved cookie like this
post_data = "p1=d1&p2=d2&p3=d3"
`curl -c cookie.txt -d "userName=USERNAME&password=PASSWORD" LOGIN SUBMIT_URL`
csv_data = `curl -X POST -b cookie.txt -d '#{post_data}' SUBMIT_URL_FOR_DOWNLOAD_CSV`