The Simple Tool to Build a Web Bot in Python

Dylan Song
Data And Beyond
Published in
3 min readApr 5, 2024

Table of Contents

· Introduction
· Importing the Selenium Library
· Opening Wikipedia on Google Chrome
· Short Video

Introduction

In this blog, I’ll show you how to automate the process of opening a website in Python, and at the end, I’ll provide you with a short video that will walk you through all the steps. The best thing about this is that it’s really easy to do and only requires a few lines of code!

Importing the Selenium Library

Selenium is a library that lets your Python program interact with the web browser. To import this library, here’s what you have to type:

I’m also going to import another library called “webdriver_manager”:

You’ll see why I import this library in the next part.

Opening Wikipedia on Google Chrome

I’m going to create a variable called “driver”:

This will install the ChromeDriverManager, which will allow the Python program to open a Google Chrome browser. Now, we have to tell Python what to do with Chrome.

In this example, I’m going to try to let Python open up the main Wikipedia page on Google Chrome. So, I need to copy the URL of Wikipedia and paste it inside the “get” method:

If you run the program, then you should get something that looks like this:

Short Video

Alright, that’s all I got for this one! If there’s anything confusing about this blog post, then make sure to check out the video below because it may be easier to follow along with a video rather than with an article. Hope to see you there, and thanks for reading!

Originally published at https://dylans0ng.github.io on April 5, 2024.

--

--

Dylan Song
Data And Beyond

Data Science Enthusiast | Blogs on any data-related content! | FREE tutorials here: https://www.youtube.com/@dylan_song