Hello!
So, when I open a Website in Chrome and press F12 I can open up the console and type in commands. I want to do the same via a script, maybe something like Node.js. I want go to any Website I want and execute console commands in my script.
Is that possible? Is there an API I have to use?
Thanks for the help! :)
You are probably looking for page automation, if you are familiar with javascript you can use PhantomJS. Take a look at page automation using PhantomJS here.
If you want to go with progamming languages like Java,C#,python,etc you can use Selenium.
check puppeteer. you can evaluate script in the context of the page
Related
I used a chrome extension to download files on site, I want to know if I can create a Python Selenium script to do the same action like what in chrome extension? is it difficult?
While this is possible it's probably not a great practice...
I am not that comfortable with python or python-selenium;
However I do understand that if it's a web driver then there probably is a way to get this accomplished, look around for Python Selenium file download API on google.
Another aproach would be to make two apps that communicate with eachother - one made with html, css, javascript, php, etc to find the name of a file on a webpage.
Then message this to python (once again not sure how to do this, it's probably on google somewhere) once the file name on the website and website name are passed to python then put them together with something like this (javascript variable joining in context example):
...
var example = pageurl_as_variable + "/" + file_name_as_variable;
some_download_function_defined_else-where(example);
...
then obviously download this as file...
Once again this isn't the best practice and you can't make a chrome extension with python due to security reasons, but as described in the example above you could make an app-hybrid and then run this on the target users computer.
There are a lot of ways to do this with just basic HTML and potentially JavaScript so your better off looking into a way to do it that way...
Here's some links to point you in the right direction:
How can I download a file from a link in HTML?
How can I download a file on a click event using selenium?
(couldn't find anything on passing messages between the apps in my 5-seconds of googling).
Is there a way to automate a server so that it can open browser at a specific time and input a given email in a form then submit it.
Yes, It can be done by using headless browsers as suggested by #TNU, I have done it using Phantom Js, Now there are many ways you can do this.
Just write a javascript in a file and schedule the job using cron from terminal.
Or you can use casperjs another library written on top of phantom Js.
Or you can use Ghost driver for connecting to phantom headless browser to execute and schedule the scripts.
Yes, you could use headless browsers, which don't have user interfaces and can be controlled programmatically. Check this list for a list of Headless Browsers
I am looking forward to program an extension for Google Chrome which runs in background and extracts information from a site. If a specific value of information equals my search parameters it should start performing some automated actions and then going back to the information-extraction loop.
Tl;DR
Language that can:
*automate web routines
*extract information
*running in background
Thanks in advance.
Using css, js and html as you do to make a website.
Look at this webpage: https://developer.chrome.com/extensions/getstarted
Is it possible to make it so I can put the user script that I made on my website and users to instal it simply by clicking on it (on firefox and chrome)?
And if it is possible how do I do it?
And how do I put my user script in chrome manually? In firefox it is simple, I just click on greasemonkey icon and select "new user script". But I simply can't figure out how to do it in chrome and couldn't find the answer online.
For me this looks like a really simple thing to do, but from some reason I can't find the answer by googling. Am I using a bad key word or something? idk.
Is it possible to make it so I can put the user script that I made on
my website and users to instal it simply by clicking on it (on firefox
and chrome)? And if it is possible how do I do it?
Yes. Just insert an ordinary download link such as
Click here to download my script!.
Please note prospective users should have Greasemonkey (Firefox) or Tampermonkey (Chrome) installed. Also, filename of the script should end with .user.js.
Example
And how do I put my user script in chrome manually? In firefox it is
simple, I just click on greasemonkey icon and select "new user
script". But I simply can't figure out how to do it in chrome and
couldn't find the answer online.
Use Tampermonkey.
I have been given a task of toggling nearly 200 users' permissions in an admin. I have access to the database, and I'm sure I can do this in SQL but I'm curious to find out how to do it this way as well, plus I suspect it will be less work because I don't have to study the SQL that's going on and I know exactly what to do after I get access to the browser instance and know how to execute javascript programmatically in the context of the web page open.
I basically want to provide a list of urls which will open ( 195 ) and then execute javascript to toggle checkboxes, then submit the form.
As I stated, I want to use firefox or chrome and I'm on linux.
This is basically what greasemonkey does.
Or, if you can do it all while staying on the same page, you can also just type in arbitrary JS code by hand in the firebug console or its Chrome equivalent. This could work if combined with some iframe trickery.
If you use Chrome, it has built in support for user automation scripts: http://userscripts.wikidot.com/, http://www.chromium.org/developers/design-documents/user-scripts
I think a cleaner solution would be for you to figure out what is the url and the parameters to pass to do what you need. Then you can just use curl to make those requests.
I use CJS Chrome extension. I add a short script take loads a script from my localhost server and executes it. The executed script can also send results back to the server.