Automating Web Browsers with Python

If you use the same tabs in a Web browser every day, it can seem menial and time consuming opening each tab individually. So, today I’m going to show you how to open all of the tabs you use with one double click.

To start off with, we’re going to need to open a text editor. For this, I’m using Visual Studio, but you can use any text editor. Just remember to save the file with a .py extension. For example: Workflow.py

To begin with, we need to import the ‘webbrowser’ module. This module is responsible for launching and controlling Web Browser Functions. If you are working on Windows, the program will use whatever browser is set as the default. In this case, the tabs will open in Firefox.

After importing the ‘webbrowser’ module, it is time to set up opening Firefox. For this demonstration I am going to load https://www.google.co.uk. The code for that is ‘webbrowser.open_new(“https://www.google.co.uk)

Now that we have written the open browser function, it is time to amend it, so that it will open the following web page in a new tab. This is simply done by amending the previous code to add ‘_tab’ on the end like so: webbrowser.open_new_tab(https://www.facebook.com)

To open any additional tabs from here will also use the ‘_new_tab’ function. This can be used to open as many tabs as needed. Printed below is the full program that I have written for this demonstration.

As displayed in the program, the file is saved as ‘WorkFlow.py’, this is a file that I have saved to the desktop. The image on the desktop shows the Python logo to confirm it has been saved as a Python executable file.

To run the program, just double-click and as you can see in the Screenshot below, it has opened the three webpages that we were setup in the program.

Congratulations, you have just automated the opening of various webpages using Python programming.

Getting Started with Python in Linux

Getting started with Python in Linux

There is no need to install Python on Linux as it comes preinstalled. After opening the Terminal, the first thing to do is to create a folder that will contain all of the Python files.
To create a folder named Python, type ‘mkdir Python’.

mkdir Command

After creating the Directory, we are now ready to create our first “Hello World” program.
To get to the Directory that was created in the previous step, use the command “cd Python”

Change Directory Command

Once we have created and moved into the Directory, we are now ready to start our first program on Linux.
To create the our first file, we are going to use the ‘Touch’ command, and name our file something that is easy to remember for later on. In this instance we are going to call the file, “Hello.py”. We have the .py extension because it is a Python File.
When we use the ‘Touch’ Command in Linux. It doesn’t look like anything has happened. However, if you type ‘ls’ and press enter. This will list all files in the current directory, and as you can see from the screenshot below, there is currently only one file in the directory.

Demonstrating File Creation and Listing in the Terminal

It is now time to edit the file, and to do this we are going to use the VIM editor. Similar to before we are going to type ‘vim’ followed by the document name. e.g. vim Hello.py
It may be difficult to see in the image below. However, there are some key things to point out. Firstly, in the bottom left corner of the window, you can see the file name that we are currently working on.
Secondly, vim opens in a ‘read-only’ mode. For us to be able to edit it, we need to press ‘I’ on the keyboard, which will allow us to start editing the document. When you start editing the document, the file name will disappear from the bottom left of the screen and be replaced with the word ‘Insert’. This lets us know that we can start making changes.

Vim Editor

You can write anything you want for your first program using Python. Type the following code:
print(“A string of Text”)
Once you are happy with the code that you have written, we need to exit vim and go back to the Terminal window. To exit vim, enter the following command: Esc key :wq!
That command will convey to the editor, that you have finished typing and that you wish to write the changes to file and quit.
It is now time to run our Python Program. To do this type: python3 Hello.py
It will display the string of text in the Terminal window, as shown below.

Output of First Python Program in Linux

Congratulations, you have just learnt some basic navigation through the Linux Terminal and created your first program in Python using Vim.

Learning SQL

I recently installed the Sololearn Application on my phone and have been working my way through the SQL and Python courses. It has been a great learning resource to use whilst on the go.
The SQL course was a good starting point in learning some of the fundamentals for writing SQL queries and seeing them in action. Whilst there was plenty of information to read through, there is also ample opportunity within the Application to put it into Practice with a sandboxed coding area. There is also a brilliant community to test yourself against in coding challenges.

Getting Started with Python on Windows

Getting started with Python in Windows

To install Python – Head to a Web Browser (Edge, Chrome or Firefox) and type https://www.python.org/downloads

Click on ‘Download Python 3.9.1’. This version could be different, it all depends upon when you’re reading this.

https://www.python.org.uk/downloads

Follow the on-screen instructions to complete the installation of Python.

When it has finished installing, open a Command Prompt and type ‘Python’. Using this Command will start Python running in the Command Prompt and also let you know which version is currently installed.

As you can see from the screenshot below. Version 3.9.1 is installed, and now we are ready to create our first program.

Show Version of Python using the Python Command

I’m going to demonstrate the printing of string of text. This can display anything you want it to. Traditionally, when learning a new programming language, the first program is called ‘Hello World’, because the output of the program is ‘Hello World’. However, in the below screenshot I’ll get it to print ‘Coding is fun!’

When you have finished coding this way, or you need to use the Command Prompt for something else. This mode can be exited using Ctrl + C followed by Ctrl + Z.

Creating the first program

Alternatively, you can create your programs using Notepad. This will require you to save the filename with .py on the end. This is so that your computer knows it a Python file. For example; Hello.py

Creating a program in Notepad

If you have created the program using Notepad. Open the Command Prompt and browse to where the file is located. Mine was saved in the Downloads folder for ease. To get here I used the Command ‘cd Downloads’. (cd = Change Directory)

Once there, type in the Command ‘py ProgramName.py’

Please note, ProgramName refers to whatever the program was named.

Showing the Output in Command Prompt

Congratulations!

If you have made it this far, you have just successfully installed Python on Windows and developed your first program.

Binary System

“There are only 10 types of people in the world: Those who understand binary and those who don’t.”
In Binary, the number ‘2’ is represented by the digits ’10’.

The binary number system is a mathmatical concept that was invented by Gottfried Leibniz in 1689. Binary is a base 2 mathmatical system that consists of two numbers: Zero and One.

The most widely used number system in place today, is the base 10 number system. Otherwise known as the Decimal system. We use this system because we have ten fingers, this makes it more natural for us to count in groups of ten.

The base 2 system is the basis for all binary code and is used everyday all around the world on any device with a processor.
In a computer system, zero and one can represent a number of different things. For example; On or Off, True or False.

In a computer chip; Zeroes represent no flow of electricity and One’s are represented by electricity flowing.
This pattern allows for any sequence of numbers of letters to be translated into binary and transmitted along a network in the form of an electrical signal.

Source: @networkingwizard

The diagram above shows how each value in binary can create a different value. When a ‘one’ occupies every space, that value becomes 256 bits. For every eight bits in binary, that adds up to a total of one byte.

Loading Screen

I started working on a Python Project earlier this week. However, it currently isn’t finished yet. The project consists of the ‘Snake’ game which used to be available on Mobile Phones in the early 2000’s. The majority of the code for the program is written. However, I’ve run into some issues when attempting to get the code to execute.
This week I have successfully developed a ‘Loading screen’. When executed in Command Line it creates a step-by-step status bar. At some point within the next few weeks I’m going to try and write the code, so that it executes as a Graphical User Interface. It is my hopes that the code will execute all on the same line before asking for a Username. Upon entering a Username, the loading screen should disappear and continue on to whichever game the loading screen is attached too.
The images below show what is displayed when the loading screen is executed in Command Line. I’ll add the code to the bottom of the page, so that if anybody wants to use it or expand upon it, then they can do.

Source: @networkingwizard
Source: @networkingwizard

Alongside this, I have decided to stick with the basics and continue following the Python for Networking Course. In addition to this, I have been using the ‘Py’ Application on my iPhone for some ‘on the go’ learning. This is helping me put in more learning time.

As of the moment, I have studied different kinds of Strings and have now moved onto Math Operators and what their function is in Python. It is my hopes to progress further through this course and have it completed by the end of February. This should be possible if I work on this for one hour, every other day. ten hours left, which gives me a couple of days room to complete this.
The next few sections on the course include; Lists, Sets and Tuples.

Once I finish this course, I’m hoping to try and complete some basic projects by incorporating all of the aspects learnt, in hopes of becoming more familiar with what each function does.

Source: @networkingwizard

Common Coding Errors

There are some steps that you can taken to aid in the learning of a new programming language. These are some of the things I’ve come across whilst attempting to learn Python Programming.

When initally learning to code, it is better to learn in small stages.
As tempting as it can be to rush through video tutorials or chapters of a textbook. It’s better to practice each section and become familiar before moving along.
It is important to conduct regular practice when attempting to learn something new. This helps cements the topic and allow you to remember.
Once you have completed several lessons, undertake a big project that incorporates all that you have learnt so far. I found this to be the biggest asset in helping to remember what each function did.

Make sure to add comments to any code that you write, this will help you identify its function later on. For example: This code prints a variable.
This will make the process easier later on when attempting to make changes to the code you’ve already written.
I found that upon returning to a project at a later date where I had failed to add sufficient comments, made it difficult for me to remember what each section of code did. This means I had to go over parts I’d already done before I could continue further.

It is important to use variable names that relate to the code you are writing, for example if you’re creating a multi-player game. Naming variables, player_1 and player_2 will help differentiate the functions for each player.

Most importantly of all, is when writing larger programs; e.g. two hundred lines of code. It is better to write each section and then test that code works before continuing on. This will help locate where the error exists within the code. The thought of completing the project and then having to error check two hundred lines of code is a somewhat daunting prospect.

Source: @networkingwizard

Whilst it is important to memory recall to attempt writing a big program by yourself, there are plenty of sources of help on the internet, such as; Google or dedicated forums where you can search for answers or ask questions that help reach the answer you’re looking for. Also, chances are, somebody has already written code similar to what you need and it should be easy enough to adapt to your project.
Caution Always be certain about what the code you are copying does before you execute it. Especially if you cannot verify the source the code came from.

As always with any new project, it is important to save the data at regular intervals. This will ensure that if anything goes wrong, you have a backup of the data.

Python: Pong Game

Source: Created by @networkingwizard

Over the last few weeks, I’ve been attempting to prepare myself to complete the 100 Days of Coding challenge which I will commit to later this year.
I feel it is important for me to learn the basics before undertaking the challenge. Not only will this help with having some understanding, it will reduce my frustration and struggle and make me less likely to quit.
For the most part, I have been using a course that I purchased on udemy. See course link here: https://www.udemy.com/course/python-programming-for-real-life-networking-use/

The Course itself, is designed to teach the basics in Python Programming for Networking and get you familiar with the concepts of Strings, Integers etc.I’m about a third of the way through the course now.
However, today I decided to deviate from the course entirely, and create a game.
After watching several game development videos on YouTube, I decided to create the ‘Pong’ Game from using Python Programming.
The video I watched to create this code can be found here: https://www.youtube.com/watch?v=XGf2GcyHPhc&t=2362s

As I followed the tutorial, I changed certain aspects of the code. What I mean by this, is that I’ve used my own variable names, and changed a few other settings, such as; The speed of the ball.
Overall, this proved to be beneficial as it aided with the learning process and helped me understand how the code works.
It did prove to be a bit of a headache at times though. At times, I would get the viable names mixed up. However, this was easily corrected. Getting the setting of the ball just right, took a fair amount of playing around. I found that when using the setting within the video, the ball flew off screen so quickly that the game would have been unplayable.
After a little bit of research, I found that setting the variable speed to 1/5 (Instead of 2, as specified in the tutorial, made the game run much smoother).

There were some really good pointers in the tutorial. It made sense to check the code after writing each section, this limits where the errors can be within the code. Therefore, making it easier to troubleshoot any problems that occurred. Also, reading what the error codes are and where the Integrated Development Environment (IDE) believes the errors are, drastically reduced the time it took to resolve the errors.

I’m happy with how my first trial turned out. Through the next few weeks, I will take breaks from the course and create the remaining games within the tutorial video. Next up, is the snake game. I’m really excited about this one, I used to play this game for hours back in the early 2000’s when I had a Nokia 3310.


Router Security

People are always buying new Devices that come onto the market, and everyday they add security to those devices in the form of Passwords and Two Factor Authentication.
However, there is one Device on a lot of Networks that always gets overlooked. That Device is the Home Router. This could also be true of small/large businesses that get broadband installed. Perhaps they just wanted to get the system up and running, and planned to change the default settings later but never got around to it.

Until recently, I was one such person. My broadband was installed a little while ago, and whilst a Password was required to access the Network, the Administrator credentials for the Router were the default settings.
Through conducting a Google search, I found that the Administrator Credentials for my Router were the first results found by the Search Engine.

To change the settings for your Router, you’ll need to login to the interface via a Web Browser. If you don’t know the IP Address of your Router, it can be found by running the Command: ipconfig /all

In the data that is displayed, you need to look for the Default Gateway Address. This is another name for the Router, it is in essence, a gateway for incoming and outgoing traffic on your Network. The ip address for your Router will probably look something like this: 192.168.1.254 This is a local address and will only be accessible whilst you are connected to the Network.
Once you have the address you’ll need to type it into the browser, to access the page.
Only change the settings that you are sure won’t break anything. Changing the default Passwords will make your network more secure. However, changing what channels 2.4Ghz and 5.0Ghz run at, may reduce the performance of your Network or cancel it out all together. If you’re unsure, save a copy of the Default Configuration to your computer before changing any settings. That way if anything goes wrong, you can factory reset the Router and then reinstall the Configuration you saved, reducing any inconvenience to other users on the Network.

If you have a lot of people who want to use your network, it maybe an idea to setup a separate Network for them to use. e.g. A Guest Network.
This runs parallel to your own Network. However, you have greater control over how this is used. For example; You can apply certain web filters, or set limits on the data streaming, reducing how much data they can upload and download whilst connect to your Network.

A Year of Change

Seeing as how this will be my first official posting on this page. I’m going to proclaim the year 2020 as the year of Computer System’s Change!
Not very catchy, I know. However, as we all know January 14th saw the end of Windows 7 support. Anybody who is still using Windows 7 has probably noticed the popup that informs the Operating System is no longer supported, and that you would be wise to upgrade to Windows 10 immediately. Either on your current system or whether you go and purchase a new one.
I would like to point out, that upgrading to Windows 10 isn’t the only option. There are other options available, please follow the link to find out what other options are available: https://network-wizard.webnode.com/l/windows-7-support/

If you are using Exchange 2010 and/or Server 2008, I should point out that support for those features also ended on January 14th. This makes them less secure and they won’t receive any future updates.

However, the fun doesn’t end there. As the year progresses, certain Applications and Features are going to be fazed out.

As of January 31st, the Cortana Application is going to be removed from iOS and Android Devices. It appears that Microsoft couldn’t get enough people to use this Application. With other ‘Voice Assistants’ available, it was just never a popular Application and never felt like a necessary or helpful addition. It will still be available on Desktop machines, if anybody out there uses it.

Along with other Microsoft feature cutbacks, Microsoft Office 2010 also makes this list. Support for this feature will end on October 13th 2020. Whilst it has been suppported by Microsoft for a decade now, in that time, has seen so many different versions of Office that its time support for this came to an end. There are versions 2013, 2016 and 2019. Along with numerous Office 365 packages that offer a multitude of different Applications for everyday needs. Alternatively, there are free and open-source versions available, such as; Libre Office. Libre Office could be beneficial if you choose to upgrade to something other than Windows 10.

For the best part of two decades, Adobe Flash Player has reigned over the internet for Videos and other multimedia. However, as of December 31st 2020. The support for this Software will be coming to an end, in favour of HTML5. This was chosen as it safer and more secure. All major Web Browsers now block Adobe Flash by default, meaning you have to unblock it within the browser settings before you can use it.
When support ends for Adobe Flash, you won’t need to do anything at all. Its only content creators that need to ensure they are not using this format by the year end.