Jump to content

Need some help with a script, not sure where to start (klicking buttons on a website, maybe selenium?)

v.zollner
Go to solution Solved by Perry M.,

I'm not a python dev, but I do have a lot of experience doing this with NodeJS + Javascript. I'd recommend using NodeJS with a very nice package called Puppeteer. It can use your built in browser, like Chrome or Firefox, to launch a webpage and control it easily.

 

I'd recommend writing a script that opens a new puppeteer instance, browses to your desired webpage and waits for the button to become visible. Once it does, it can easily be clicked.

 

Install NodeJS: here.

Create a new folder for your project.

Run `npm init` and enter some details.

Install Puppeteer: `npm install puppeteer --save`.

Create a new `index.js` file and get editing..

 

I'd recommend following with an example first, and then modify it to suit your needs. You can absolutely execute this as a task as Nodejs just takes the JS file path as the first argument, and then executes it. You could even make a BAT file to wrap it so you have a single Windows executable.

Hi! I would like to write a short script that opens a URL and klicks on a single button. Ideally it should be executable via the Windows task scheduler. (as far as I know that means it should be a .exe

I do have a small amount of coding experience in python and bash, but I'm not sure where to start and I have failed to come up with good Google search terms to find a solution. I'm a biology major and my coding education only covered data analysis. 

Can someone maybe direct me towards a tutorial or help me find a starting point from where I can approach this project? I'm happy to watch a couple of hours of Youtube tutorials or read through a bunch of documentations before giving it a go, but i really dont know where to begin. 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just open notepad and type there 

 

explorer.exe  https://www.google.com

 

File> Save as ... select all file types and enter put .CMD after the file name.  OR .BAT, but .CMD is the modern version of batch file.

Replace google.com with whatever.

 

The command starts windows explorer, which determines it's a web address, so it passes the address to the default web browser.

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

6 minutes ago, mariushm said:

Just open notepad and type there 

 

explorer.exe  https://www.google.com

 

File> Save as ... select all file types and enter put .CMD after the file name.  OR .BAT, but .CMD is the modern version of batch file.

Replace google.com with whatever.

 

The command starts windows explorer, which determines it's a web address, so it passes the address to the default web browser.

 

 

 

Thanks for the Quick reply, but this would only open the Website, but not perform any actions on it. 

 

I have found someone on reddit reccomending selenium as a possible solution for a similar issue. Has anyone here used selenium and can confirm if this is a viable approach? 

Link to comment
Share on other sites

Link to post
Share on other sites

I'm not a python dev, but I do have a lot of experience doing this with NodeJS + Javascript. I'd recommend using NodeJS with a very nice package called Puppeteer. It can use your built in browser, like Chrome or Firefox, to launch a webpage and control it easily.

 

I'd recommend writing a script that opens a new puppeteer instance, browses to your desired webpage and waits for the button to become visible. Once it does, it can easily be clicked.

 

Install NodeJS: here.

Create a new folder for your project.

Run `npm init` and enter some details.

Install Puppeteer: `npm install puppeteer --save`.

Create a new `index.js` file and get editing..

 

I'd recommend following with an example first, and then modify it to suit your needs. You can absolutely execute this as a task as Nodejs just takes the JS file path as the first argument, and then executes it. You could even make a BAT file to wrap it so you have a single Windows executable.

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Perry M. said:

I'm not a python dev, but I do have a lot of experience doing this with NodeJS + Javascript. I'd recommend using NodeJS with a very nice package called Puppeteer. It can use your built in browser, like Chrome or Firefox, to launch a webpage and control it easily.

 

I'd recommend writing a script that opens a new puppeteer instance, browses to your desired webpage and waits for the button to become visible. Once it does, it can easily be clicked.

 

Install NodeJS: here.

Create a new folder for your project.

Run `npm init` and enter some details.

Install Puppeteer: `npm install puppeteer --save`.

Create a new `index.js` file and get editing..

 

I'd recommend following with an example first, and then modify it to suit your needs. You can absolutely execute this as a task as Nodejs just takes the JS file path as the first argument, and then executes it. You could even make a BAT file to wrap it so you have a single Windows executable.

Thanks a lot, it looks like pupeteer is exactly what i was looking for. Now i just have to learn some JavaScript lol. Well, I'm on vacation so I have plenty of time, and it should'be too hard, right? 

Link to comment
Share on other sites

Link to post
Share on other sites

@v.zollner It's not, but it can look that way. If you have any troubles I'd be happy to help.

 

I honestly love writing browser automations using this setup.. It's pretty powerful and can be used for most sites that either don't require a login or at least don't require 2FA. I've used it to pull metrics from a number of API-less sites before and it's robust so long as the website owners don't update their source too much.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×