For example, you could go to the login page of Facebook with Chrome, open the console and type
document.getElementById("email").value = "myemailaddress#example.com";
document.getElementById("pass").value = "hunter42";
document.getElementById("login_form").submit();
and it would log you in (assuming correct login information).
How would you do this from the Windows cmd or with a batch file?
Automating logging into a website is my main obstacle for creating an automation where a script sends me a text message when I receive a new grade on my school's web portal.
I've experimented with doing a form submission with cURL in PHP, but the login form is very complex with a lot of hidden fields and whatnot.
Personal project aside, I really want to know if you're able to run a JS Script on a specific web page because there are a ton of circumstances where this could be useful.
Thanks!
You're not going to be able to do it from the command line (which includes the run dialog). Your best bet is to find a headless browser framework like Selenium or PhantomJS. I've used PhantomJS, CasperJS, and NightmareJS to much success in the past and would recommend them especially if you're familiar with JavaScript already.
Related
I am trying to create a bot to buy tickets automatically from this website https://kide.app/products/96ad9c18-66b3-43e5-88f2-c55d9da3c227
So far I have succesfully made it that when I run the script it automatically logins to the site with my account and password. I used f12 and inspect element to copy the right parts of javascript which was relatively easy. But when I try to do the same thing with the add to cart feature, I can't find the right part from the code to copy. Is there some protection to block the making of such scripts or what?
When a webpage like https://poloniex.com/exchange#btc_eth is opened in the browser, we see that the browser constantly shows updated buy and sell orders. Also, in the Elements section in the chrome console, these updates are visible in the HTML tables.
Is there a way I can use a nodejs script run on my pc (so not in the browser console) to get these live html table updates from that website, without having to do a GET request every time?
If the chrome browser is able to do it, nodejs / jQuery / ajax should be able to do it as well. I tried the XMLHttpRequest nmp module but no luck yet.
It's possible they are using token authentication which means you wouldn't be able to get all the connection info you need just from their client-side code. Have you downloaded it and looked at it yet?
If you find it's not possible to call their services, there are other free products designed for webscraping. AutoHotKey is one that can open a web page and traverse its DOM. I believe it has the ability to run in the background, but don't quote me.
My requirement is to write one script when I run the script it opens the page and fill the fields and automatically take me to next page.
For e.g. Script for www.irctc.co.in. When we login to irctc it ask the user name and password and when click on submit it redirect to next page.
I want to write a script in such a way that I just click on the script it internally does all these things and I could see the next page.
I am unable form where I should start.
I think you are looking for something like Greasemonkey: https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/
Greasemonkey is a Mozilla Firefox extension that allows users to install scripts that make on-the-fly changes to web page content after or before the page is loaded in the browser.
If you use a different browser, then you can refer to: http://en.wikipedia.org/wiki/Greasemonkey#Equivalents_for_other_browsers
Check Watir - Web Application Testing in Ruby. Although it is used for automation, it might solve the purpose here. With Watir, you write scripts in ruby and execute it and then see the magic. More information can be found here
Note: I haven't been able to find question on the site, if it exists close this as duplicate.
For out application we have a browser based client using javascript. Our application follows client server architecture, but is deployed only on premise ie it is not exposed to web.
I am thinking of providing limited scripting support to user (using javascript) somewhat similar to that providing in desktop based application (like matlab)
Is it safe to allow user to script.
What is the safe way to implement (eval, using iframe etc)
From a security perspective: Running scripts on the page is not a problem, A user can already do that by pressing f12 and opening up the console.
The problem is if you allow users to save js into your db which is then loaded on the page by another user.
Imagine if you had a commenting system that allowed script tags, a potential prankster can now perform any of the functions the user can.
Or even anchor tags click on me
If it is just for the user, I would append the scripts to the body.
var scr = document.createElement("script");
scr.textContent = 'alert("hi")';
document.body.appendChild(scr);
I want to emulate some human(not for spam use) for some my daily works. I don't want to use some curl/wget solution because it will include some works to analyze the HTTP package sent by browser. So, basically:
I will use the browser(eg. chrome) to login the system, so I have login state in that browser.
I open the search page for the system, and by any way I start the script.
The script will input some string into the input, and submit the form.
The browser redirects to the result page, and my script will analyze the result page and get the things I want.
Is there any existing solutions that I can use to write such script? The functionality should include:
fill in some and submit the form
in the result page the script can analyze the webpage and get the desired data.
I was trying to do it in but the domain for my program and the system that I want to run in is not in the same domain.
You may be interested in famous Selenium:
Selenium automates browsers. That's it. What you do with that power is
entirely up to you. Primarily it is for automating web applications
for testing purposes, but is certainly not limited to just that.
Boring web-based administration tasks can (and should!) also be
automated as well.
See its DEMO here.
Or you may be interested in iMacros addon of Firefox depending on your requirements.