Hack Web Views With A Selenium Python Bot

Hack Web Views With A Selenium Python Bot

Hi fellow hacker😂, do you want to increase your youtube views, page views or send traffic to your social media profiles, blog or bot-created analytics.

images-removebg-preview (3).png
Today, we shall create a simple python web bot that opens a specific URL in a browser of your preference and get those views!

We shall be using Selenium! So, What is Selenium?
Selenium is an open-source software suite of browser automation tools that automate web browser interactions, created for testing purposes.

Selenium’s Tool Suite

We’re not going to exhaust you with a long explanation of Selenium’s tool suite (you can check that out on Selenium’s own website if you want). Instead, we’ll give you a brief overview of the tools and their key differences.

Selenium-Tools-removebg-preview.png
🛠 Selenium IDE
Selenium IDE is a Chrome, Firefox and Edge extension that makes it easy to record and playback tests in the browser.

🛠 Selenium WebDriver
Selenium WebDriver drives a browser natively, as a real user would, either locally or on remote machines.

🛠 Selenium Grid
Selenium Grid takes WebDriver to another level by running tests on many machines at the same time, cutting down on the time it takes to test on multiple browsers and operating systems.

SeleniumTesting-removebg-preview.png
On a high level, Selenium can help you test software by automating tests. Automated testing, as opposed to manual testing, is beneficial as it allows you to complete testing tasks faster and with fewer errors.

The Hack:

Since I am using Windows, I will use chocolatey to install Selenium and therefore you must run in an elevated command. (Admin privileges or PowerShell)

Chocolatey is a software management automation for Windows that wraps installers, executables, zips, and scripts into compiled packages.

Chocolatey or Choco as it is sometimes referred to is a free, open-source package manager for Windows that is very similar to Apt or DNF in the Linux realm.

I think It comes installed by default in Windows 10+ but if it is not installed, check out the official docs for installing or this step by step guide by Liquid Web.

To verify that Chocolatey is installed, we will use the choco command.

image.png

I am using python, so we install selenium first (might require elevated rights)

pip install selenium

Install the chrome driver or you can see other browser options or os options from here .

choco install chromedriver

image.png

You may add this to the path, but in this article, I won't! I will include it in my code!
Mine installed here:
image.png

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

The above code simply imports our dependencies:
The class selenium.webdriver.common.keys.Keys handles all Keys in Selenium Python. It contains a huge number of key methods one can use in Selenium Python.

You can actually do a lot with this class!

So my path is:

path = "C:/ProgramData/chocolatey/lib/chromedriver/tools/chromedriver.exe"

Note the slashes used otherwise you will have os errors!

Creating the URL page I want to auto-view! Replace it with any link especially those that can be viewed publically without logging in and this applies to most websites like Youtube, Social Media, Blogs, GitHub etc..!

url = "https://www.youtube.com/watch?v=eZyr8afY4bk"
no_of_views = 50
duration = float(10)

The logic:

for i in range(0,no_of_views):
    browser = webdriver.Chrome(path)
    browser.get(url)
    browser.find_element_by_tag_name('body').send_keys(Keys.SPACE)

    time.sleep(duration)

    print(str(i+1) + " iterations done")
    browser.quit()

The body tag loads the entire content.

Run the script: python web_view_bot.py
The browser tap will auto pop up and close after the passed time.sleep(duration) and this is what you will see:

image.png You can change the timer regarding website restrictions, make necessary edits
End of Day Output: image.png Please note that some methods might have been deprecated, consider reading official docs for the latest version.

If a website requires login, you can still use selenium or combine it with requests! Check my requests implementation article .

That's It! See Full Code Here.

If you enjoyed reading, consider subscribing and reacting to this with love by sharing, commenting and any criticism is much welcome.

📢Follow me on Twitter:

Ronnie Atuhaire