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

January 8, 2016 | Views: 11571

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

(Note: For Video Demo/Lab, on this part, you can follow this link: 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‘http://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:‘http://site name 1 here’)‘http://site name 2 here’)

The final code/script looks like this:

import webbrowser‘’)‘’)‘’)


Step 3: Save the file as, (test = file name)

Let’s see it in Python Shell and let’s execute


(Note: For Video Demo/Lab, on this part, you can follow this link: In the video, I mention Part 5 FYI.)

Share with Friends
Use Cybytes and
Tip the Author!
Share with Friends
Ready to share your knowledge and expertise?
  1. what is the default web browser the module uses? or can we mention our own?

  2. I’d just like to suggest a great read – Violent Python by T. J. O’Connor

  3. And where is that amazing hacking potential in your txt and vid? Do a research first and then write something really useful. I would highly recommend Selenium. Anything ‘hackerous’ on that? Or next copy-paste way of pretending to be a good infosec specialist?

    • selenium is good for automation but can u tell how to fill captcha with it.. I made a script to get the result from a collage website but, captcha is creating a problem.

    • There will always be those who do not see the value in learning tidbits. It’s the great intellects who can tell how to use these tidbits to their full potential. For instance did you ever consider sticking in a website that you control. It’s such a simple way for someone to send the hapless victim to a site loaded with malware. Now is this the most insightful article? No. No it is not. But you put your own article out there, to be judged, before you mock someone else’s attempts. As a community it is better that we encourage others, unless you believe it is better to drag others down in an attempt to better our own egos.

Page 3 of 3«123
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge


We recommend always using caution when following any link

Are you sure you want to continue?