Home 0P3N Blog Python Programming for Hackers (Part 3) – Writing Scripts for Opening Multiple Websites at Once
Ready to Start Your Career?
Create Free Account
By: bjacharya
January 8, 2016

Python Programming for Hackers (Part 3) – Writing Scripts for Opening Multiple Websites at Once

By: bjacharya
January 8, 2016
By: bjacharya
January 8, 2016
green-glass-mosaic-cybrary
(Note: For Video Demo/Lab, on this part, you can follow this link: https://youtu.be/iAXbbIGG6l0. In the video, I mention Part 5 FYI.)Hello all and welcome to Part 3 of Python Programming For Hackers. Here, I'll show you the script of Python, which can be used to open multiple websites at once. Run one script and open 100+ websites at once.Before writing scripts, I want to explain something. I use 'module' in the script. And, what's a module ?Module: To make programming easier, Python has Modules. Modules contain useful code and help in extending Python’s functionality. Let's begin:If you get confused, please refer the video demo link given above and at the bottom of this article. Step 1 : Open Python Shell, and open new file (and type)

import webbrowser

In Python, the ‘import’ statement is used to add a module to your project. In this case, we want to add the ‘webbrowser’ module Step 2 : Type

webbrowser.open(‘https://site name here’)

Here, we're calling the open function on our default web browser. We pass it a URL in the form of a string. We can add as many websites as we want. For example:

webbrowser.open(‘http://site name 1 here’)

webbrowser.open(‘http://site name 2 here’)

The final code/script looks like this:

import webbrowser

webbrowser.open(‘http://google.com’)

webbrowser.open(‘http://facebook.com’)

webbrowser.open(‘http://itsolutionpokhara.com’)

 Step 3: Save the file as, test.py (test = file name)Let’s see it in Python Shell and let’s execute test.py (Note: For Video Demo/Lab, on this part, you can follow this link: https://youtu.be/iAXbbIGG6l0. In the video, I mention Part 5 FYI.)
Request Demo

Build your Cybersecurity or IT Career

Accelerate in your role, earn new certifications, and develop cutting-edge skills using the fastest growing catalog in the industry