Ask coding questions

← Back to all posts
Making a bot to do daily tasks on the internet
piphi (6)


I'm interested in writing a robot that'll do some things on the internet everyday, such as making a new wiki page, how would I go about making this?

More details:
I want the bot to go to a specific website, click a text entry, enter a number, then go to another website, copy all the text there, and paste it into a wiki page.

It should do this once a day.

I also want the bot to do this without me having to turn on my computer if possible.


piphi (6)
SixBeeps (5334)

Anything that interacts with the web will usually involve an API, though you might be able to do it through a webdriver.
Being able to do this without having to have your computer be on requires one that will. This is usually done with a server, either onsite or offsite. Either way, it's not ideal.

tussiez (1676)

Typically APIs are used for this kind of task. Do you have any specifics on what page(s) you are using?

piphi (6)

Thanks for answering so soon!

How would I make an API? Would I be using JS?

There's a game that I play called Greed Control, here. The instructions for the game are here. Basically I want the robot to go to the first link, enter a number. Then go to the scores page and copy everything (the equivalent of pressing Ctrl A then Ctrl C). Next, paste what it copied into a wiki page with yesterday's date in it's title, for example if I ran the code today it would give me this wiki page:
I also want it to go to the statistics page and copy variables d1 and d2:

Then paste them into the wiki page created before.

In the end it should look like this.

Please tell me if I should explain some more.


tussiez (1676)

@piphi Thanks for the reply!
Interesting. I'm not very familiar with Python, but I hear you can interact with the web browser and do exactly what you said, press keys, click things, etc.
I'm not super sure on exactly how you would get the variables, as you have to render the page, and then inspect the code. Or maybe not, I don't know.

If you do know some Python, try using the Pygame browser(?)

import webbot
import os
import time
import random
os.system('pip3 install pyautogui')
driver = webbot.Browser()
while True:

Again, I don't know much Python, but I've seen that it's possible to do about exactly what you said.

tussiez (1676)

@piphi For JavaScript, you can load an iFrame of the page. This will give you access to the document, and here you can enter a number. You will need to get the element name/id/class to set the number, and you can get the element with this:

Getting page + putting in number

<iframe src="greedPageLink" id="greedPage"></iframe>
var greedPage = document.getElementById('greedPage');
var greedWindow = greedPage.contentWindow;
//greedWindow is like the local window. You can do document.getElementById(), get elements, etc
var numberBox = greedWindow.document.getElementById('some-id');
//I don't know the id for the input box, find it in Inspect :)
numberBox.value = YOURNUMBER;//This is the number you want to put in.

var submitButton = greedPage.document.getElementById('some-id');//Again, I don't know the id of the submit button, you can find it on your own;//Click the submit button

That submits the form with your number.

Getting Graph Data

We're using the same script as before, just adding to it here.
Luckily for us, the variables are global! :)
This means all we need to do to get the graph data is

var d1 = greedPage.d1;//This is the data
var d2 = greedPage.d2;
tussiez (1676)

@piphi This eerily sounds like a school assignment lol

tussiez (1676)

@tussiez Unfortunately, it appears that CORS is blocking the page load.. the above code should work as long as you get the page to load in an iFrame

piphi (6)

@tussiez What did you change? I thought you couldn't get around CORS. lol, this isn't a school assignment, just a project.

piphi (6)

@tussiez your repl is still not working and I don't know what to do next, so if someone could help that'd be great.

tussiez (1676)

@piphi Ah
So I used someone's Heroku server that seems to get around CORS.
My Repl is working, and check the console. Ignoring the errors, there are TWO arrays logged. This is the graph data.

tussiez (1676)

@piphi You can use that data however you wish.

piphi (6)

@tussiez thanks, is there any way to login to my account in that website while inside the iframe?

tussiez (1676)

@piphi No idea.. I'm also stumped on this part