Lets make a python bot :) part 1 for beginners :))
generationXcode (530)

😎💻 bots r cool :)

Ok guys this is the second time I'm writing this!!!
We are making a bot today with python. This aint no discord bot. Nonono! this is a web bot (or whatever thats called)

This tutorial will be shorter than the last because even I dont have that large of an attention span in a tutorial and I want people to learn from what I make

Our bot will search up in repl answers and get an answer(the first) for our question that we type in our bot

the code

Lets get our hands dirty with some code now


we need selenium as the webdriver library for this project.
First you need to install it by writing this in your cmd/terminal:

python -m pip install selenium


py -m pip install selenium

now write this in your file:

from selenium import webdriver

get the question

Now we need the question that the user wants to search ->

question=input("what do you want an answer for?")

Thats how python gets inputs.
Now that we have that lets get our driver


First download firsfox cus thats what we are using here and trust me you will thank me (even tho I'm using chrome while writing this)

Now get the gecko driver for firefox (what we need for the automation) from here:

Now get the path of the driver (gecko driver) the web driver that you just downloaded and put this in your code:

driver = webdriver.Firefox(executable_path = '[path]')

My path was something like this : driver = webdriver.Firefox(executable_path = '[path]/geckodriver-v0.26.0-win64/geckodriver.exe')

Ok now!

get the link!!!

Here we can actually search something on replit by entering a link! like this :

we are going to take advantage of this hahaha to do that we can easily just write this:


So done now!

clicking on the question to load it in

Now I searched up al lot of these answers and I got a css selector. I have it ready for you in this code so you need not do the work but you should know that its quite easy to do from the devtools :)

here is the code:

driver.execute_script("document.querySelector('div.posts-feed-item:nth-child(1) > div:nth-child(1) > a:nth-child(1) > div:nth-child(1)').click()")

Now thats all for this lesson. here is all the code together:

from selenium import webdriver
question=input("what do you want an answer for?")
driver = webdriver.Firefox(executable_path = '[path]/geckodriver-v0.26.0-win64/geckodriver.exe')
driver.execute_script("document.querySelector('div.posts-feed-item:nth-child(1) > div:nth-child(1) > a:nth-child(1) > div:nth-child(1)').click()")

Now this is a start of what (hopefully) will be a series. I need your inputs from the comments section on what to do now :)

also dont try this on replit do it locally because it doesnt work on replit...

Thats it for today and happy coding

^ that's me right there, no a bit to the side now a bit right - yes! Right there in the middle!

You are viewing a single comment. View All
AnasAAlam (0)

can i run this in replit.com