Intro to Python – Whiteboard Friday

Intro to Python – Whiteboard Friday

Intro to Python – Whiteboard Friday 1920 1280 Britney Muller

Python is a programming language that can help you uncover incredible SEO insights and save you time by automating time-consuming tasks. But for those who haven’t explored this side of search, it can be intimidating. In this episode of Whiteboard Friday, Britney Muller and a true python expert named Pumpkin offer an intro into a helpful tool that’s worth your time to learn.

Click on the whiteboard image above to open a high resolution version in a new tab!

Video Transcription

Hey, Moz fans. Welcome to another edition of Whiteboard Friday. Today we’re talking all about introduction to Python, which is why I have a special co-host here. She is a ball python herself, total expert. Her name is Pumpkin, and she’s the best. 

What is Python?

So what is Python? This has been in the industry a lot lately. There’s a lot of commotion that you should know how to use it or know how to talk about it. Python is an open source, object-oriented programming language that was created in 1991.

Simpler to use than R

Some fun facts about Python is it’s often compared to R, but it’s arguably more simple to use. The syntax just oftentimes feels more simple and common-sense, like when you’re new to programming. 

Big companies use it

Huge companies use it. NASA, Google, tons of companies out there use it because it’s widely supported.

It’s open source

It is open source. So pretty cool. While we’re going through this Whiteboard Friday, I would love it if we would do a little Python programming today. So I’m just going to ask that you also visit this in another tab, python.org/downloads. Download the version for your computer and we’ll get back to that. 

Why does Python matter?

So why should you care? 

Automates time-consuming tasks

Python is incredibly powerful because it helps you automate time-consuming tasks. It can do these things at scale so that you can free up your time to work on higher-level thinking, to work on more strategy. It’s really, really exciting where these things are going. 

Log file analysis

Some examples of that are things like log file analysis. Imagine if you could just set up an automated system with Python to alert you any time one of your primary pages wasn’t being crawled as frequently as it typically is. You can do all sorts of things. Let’s say Google crawls your robots.txt and it throws out a server error, which many of you know causes huge problems. It can alert you. You can set up scripts like that to do really comprehensive tasks. 

Internal link analysis

Some other examples, internal link analysis, it can do a really great job of that. 

Discover keyword opportunities

It can help you discover keyword opportunities by looking at bulk keyword data and identifying some really important indicators. 

Image optimization

It’s really great for things like image optimization. It can auto tag and alt text images. It can do really powerful things there. 

Scrape websites

It can also scrape the websites that you’re working with to do really high volume tasks. 

Google Search Console data analysis

It can also pull Google Search Console data and do analysis on those types of things.

I do have a list of all of the individuals within SEO who are currently doing really, really powerful things with Python. I highly suggest you check out some of Hamlet Batista’s recent scripts where he’s using Python to do all sorts of really cool SEO tasks. 

How do you run Python?

What does this even look like? So you’ve hopefully downloaded Python as a programming language on your computer. But now you need to run it somewhere. Where does that live? 

Set up a virtual environment using Terminal

So first you should be setting up a virtual environment. But for the purpose of these examples, I’m just going to ask that you pull up your terminal application.

It looks like this. You could also be running Python within something like Jupyter Notebook or Google Colab. But just pull up your terminal and let’s check and make sure that you’ve downloaded Python properly. 

Check to make sure you’ve downloaded Python properly

So the first thing that you do is you open up the terminal and just type in “python –version.” You should see a readout of the version that you downloaded for your computer. That’s awesome. 

Activate Python and perform basic tasks

So now we’re just going to activate Python and do some really basic tasks. So just type in “python” and hit Enter. You should hopefully see these three arrow things within your terminal. From here, you can do something like print (“Hello, World!”). So you enter it exactly like you see it here, hit Enter, and it will say “Hello, World!” which is pretty cool.



You can also do fun things like just basic math. You can add two numbers together using something like this. So these are individual lines. After you complete the print (sum), you’ll see the readout of the sum of those two numbers. You can randomly generate numbers. I realize these aren’t direct SEO applications, but these are the silly things that give you confidence to run programs like what Hamlet talks about.

Have fun — try creating a random number generator

So I highly suggest you just have fun, create a little random number generator, which is really cool. Mine is pulling random numbers from 0 to 100. You can do 0 to 10 or whatever you’d like. A fun fact, after you hit Enter and you see that random number, if you want to continue, using your up arrow will pull up the last command within your terminal.

It even goes back to these other ones. So that’s a really quick way to rerun something like a random number generator. You can just crank out a bunch of them if you want for some reason. 

Automating different tasks

This is where you can start to get into really cool scripts as well for pulling URLs using Requests HTML. Then you can pull unique information from web pages.

You can pull at bulk tens of thousands of title tags within a URL list. You can pull things like H1s, canonicals, all sorts of things, and this makes it incredibly easy to do it at scale. One of my favorite ways to pull things from URLs is using xpath within Python.

This is a lot easier than it looks. So this might be an xpath for some websites, but websites are marked up differently. So when you’re trying to pull something from a particular site, you can right-click into Chrome Developer Tools. Within Chrome Developer Tools, you can right-click what it is that you’re trying to scrape with Python.

You just select “Copy xpath,” and it will give you the exact xpath for that website, which is kind of a fun trick if you’re getting into some of this stuff. 

Libraries

What are libraries? How do we make this stuff more and more powerful? Python is really strong on its own, but what makes it even stronger are these libraries or packages which are add-ons that do incredible things.

This is just a small percentage of libraries that can do things like data collection, cleaning, visualization, processing, and deployment. One of my favorite ways to get some of the more popular packages is just to download Anaconda, because it comes with all of these commonly used, most popular packages.

So it’s kind of a nice way to get all of it in one spot or at least most of them. 

Learn more

So you’ve kind of dipped your toes and you kind of understand what Python is and what people are using it for. Where can you learn more? How can you start? Well, Codecademy has a really great Python course, as well as Google, Kaggle, and even the Python.org website have some really great resources that you can check out.

This is a list of individuals I really admire in the SEO space, who are doing incredible work with Python and have all inspired me in different ways. So definitely keep an eye on what they are up to:

But yeah, Pumpkin and I have really enjoyed this, and we hope you did too. So thank you so much for joining us for this special edition of Whiteboard Friday. We will see you soon. Bye, guys.

Video transcription by Speechpad.com

* Checkbox GDPR is required

*

I agree

Will you like to book a consultation today?

We promise you’ll be glad to have us as the only premium website developer you’ve ever had!

Will you like to book a consultation today?

We promise you’ll be glad to have us as the only premium website developer you’ve ever had!

Bear Design - WordPress Development

Bear Design provides website development and design, creating content uploaded websites and improving web page placements and web traffic. Bear Design websites are unique, easy to use and responsive. Site owners can easily edit the content, or can trust the Bear Design & Communications to keep them up to date and supply quality content regularly.


GET IN TOUCH
160 City Road, EC1V 2NX London, United Kingdom
Monday – Thursday: 9:00 AM – 5:00 PM
Friday: 9:00 AM – 2:00 PM

WE ARE IN LONDON

Bear Design - WordPress Development

Bear Design provides website development and design, creating content uploaded websites and improving web page placements and web traffic. Bear Design websites are unique, easy to use and responsive. Site owners can easily edit the content, or can trust the Bear Design & Communications to keep them up to date and supply quality content regularly.


WE ARE IN LONDON

GET IN TOUCH
160 City Road, EC1V 2NX London, United Kingdom
Monday – Thursday: 9:00 AM – 5:00 PM
Friday: 9:00 AM – 2:00 PM

Bear Design - WordPress Development

Bear Design provides website development and design, creating content uploaded websites and improving web page placements and web traffic. Bear Design websites are unique, easy to use and responsive. Site owners can easily edit the content, or can trust the Bear Design & Communications to keep them up to date and supply quality content regularly.


GET IN TOUCH
160 City Road, EC1V 2NX London, United Kingdom
Monday – Thursday: 9:00 AM – 5:00 PM
Friday: 9:00 AM – 2:00 PM

WE ARE IN LONDON

© Made with by Bear Design

© Made with by Bear Design

    We are Bear Design

    WE DESIGN

    YOUR WORLD

    Bear Design & Communications Ltd.

    Address : 160 City Road, EC1V 2NX London, United Kingdom
    Phone : +36 702 448 100
    Email : [email protected]

    Opening hours :
    Monday – Thursday: 9:00 AM – 5:00 PM
    Friday: 9:00 AM – 2:00 PM

    Are you sure?
    You must approve our cookie policy to use our site. I you refuse it you will redirect to the Google.
    Refuse
    Approve Cookies
    Cookie Policy
    Cookie Policy
    This Bear Design Cookie Policy (“Policy”) outlines the general policy, practices, and types of cookies that Bear Design And Communications Ltd.. (“Bear Design”, “we”, “us” or “our”) may use to improve our services and your experience when visiting our websites.Cookies are small pieces of text used to store information on web browsers. They’re used by many websites to store and receive identifiers and other information on devices, such as a handheld phone or computer. Our site and services use cookies and other similar technologies (collectively in this Policy, “cookies”), in order to provide a better service to you and to generally improve our sites and services. For example, we may use cookies to help direct you to the appropriate part of our websites, by indicating that you are a repeat visitor. We may also use information to present you with services that are matched to your preferences.Some portions of our websites are functional without cookies, and you may generally choose whether to accept cookies. Most web browsers are set to accept cookies by default, however, you may be able to delete cookies yourself through your browser’s cookie manager. To do so, please follow the instructions provided by your web browser. Please note that disabling cookies will reset your session, disable auto-login, and may adversely the availability and functionality of our websites and the services we can provide to you.As part of our services, we may also place cookies on the computers of visitors to websites protected by Bear Design. We do this in order to identify malicious visitors, reduce the chance of blocking legitimate users, and to provide customized services.Our websites use first party cookies (i.e., cookies set directly by Bear Design) as well as third party cookies, as detailed in the table below.
    Type of CookieWhy we use these cookiesWho serves them and where can you find out more information?
    Analytics and research of usersThese are used to understand, improve, and research users visiting //beardesign.me and their needs for our product offerings. For example, we may use cookies to understand what pages a user browses before submitting a sales request form. We do not share information about this analysis with any third parties.Selected third parties listed and defined as follows:
    • Google Analytics – Web traffic tracking – //www.google.com/policies/privacy/
    • Bing – Conversion tracking from Bing ads – https://advertise.bingads.microsoft.com/en-us/resources/policies/microsoft-bing-adsprivacy-policy
    • Doubleclick – Google advertising platform that analyzes browsing activity across website to establish user profile – //www.google.com/policies/technologies/ads/
    • Twitter – Analyzes browsing activity across website to establish user profile – https://support.twitter.com/articles/20170514
    • Facebook – Analyzes browsing activity across website to establish user profile – https://www.facebook.com/policies/cookies/
    A user can delete these cookies through browser settings.
    Improving Website experienceThese provide functionality to help us deliver a better user experience for our website. For example, cookies help facilitate chats with our sales representatives, allow you to search the website, and deliver the user quickly to their intended website location.1st party and selected third parties as defined below:
    • __cfduid 3rd party cookie – This cookie is strictly necessary for Cloudflare’s security features
    • __hssc Cookie for keeping track of sessions. This is used to determine if we should increment the session number and timestamps in the __hstc cookie. It contains: the domain, viewCount (increments each pageView in a session), session start timestamp. (Expires: 30 min)
    • __hssrc Whenever HubSpot changes the session cookie, this cookie is also set. We set it simply to the value “1”, and use it to determine if the user has restarted their browser. If this cookie does not exist when we manage cookies, we assume it is a new session. (Expires: None. Session cookie)
    • __hstc The main cookie for tracking visitors. It contains: the domain, utk (see below), initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session) (Expires: 2 years)
    • hsfirstvisit This cookie used to keep track of a user’s first visit. (Expires: 10 years)
    • hubspotutk This cookie is used for to keep track of a visitor’s identity. This cookie is passed to HubSpot on form submission and used when deduplicating contacts. (Expires: 10 years)
    • wordpress_ WordPress cookie for a logged in user.
    • wordpress_logged_in_ WordPress cookie for a logged in user.
    • wp-settings- WordPress also sets a few wp-settings-[UID] cookies. The number on the end is your individual user ID from the users database table. This is used to customize your view of admin interface, and possibly also the main site interface.
    • wp-settings-time- WordPress also sets a few wp-settings-{time}-[UID] cookies. The number on the end is your individual user ID from the users database table. This is used to customize your view of admin interface, and possibly also the main site interface.
    • __cfduid 3rd party cookie – This cookie is strictly necessary for Cloudflare’s security features
    A user can delete these cookies through browser settings.
    LAST UPDATE: 24.01.2018, LONDON
    Approve
    Refuse
    Cookie Policy
    This Bear Design Cookie Policy (“Policy”) outlines the general policy, practices, and types of cookies that Bear Design And Communications Ltd.. (“Bear Design”, “we”, “us” or “our”) may use to improve our services and your experience when visiting our websites.Cookies are small pieces of text used to store information on web browsers. They’re used by many websites to store and receive identifiers and other information on devices, such as a handheld phone or computer. Our site and services use cookies and other similar technologies (collectively in this Policy, “cookies”), in order to provide a better service to you and to generally improve our sites and services. For example, we may use cookies to help direct you to the appropriate part of our websites, by indicating that you are a repeat visitor. We may also use information to present you with services that are matched to your preferences.Some portions of our websites are functional without cookies, and you may generally choose whether to accept cookies. Most web browsers are set to accept cookies by default, however, you may be able to delete cookies yourself through your browser’s cookie manager. To do so, please follow the instructions provided by your web browser. Please note that disabling cookies will reset your session, disable auto-login, and may adversely the availability and functionality of our websites and the services we can provide to you.As part of our services, we may also place cookies on the computers of visitors to websites protected by Bear Design. We do this in order to identify malicious visitors, reduce the chance of blocking legitimate users, and to provide customized services.Our websites use first party cookies (i.e., cookies set directly by Bear Design) as well as third party cookies, as detailed in the table below.
    Type of CookieWhy we use these cookiesWho serves them and where can you find out more information?
    Analytics and research of usersThese are used to understand, improve, and research users visiting //beardesign.me and their needs for our product offerings. For example, we may use cookies to understand what pages a user browses before submitting a sales request form. We do not share information about this analysis with any third parties.Selected third parties listed and defined as follows:
    • Google Analytics – Web traffic tracking – //www.google.com/policies/privacy/
    • Bing – Conversion tracking from Bing ads – https://advertise.bingads.microsoft.com/en-us/resources/policies/microsoft-bing-adsprivacy-policy
    • Doubleclick – Google advertising platform that analyzes browsing activity across website to establish user profile – //www.google.com/policies/technologies/ads/
    • Twitter – Analyzes browsing activity across website to establish user profile – https://support.twitter.com/articles/20170514
    • Facebook – Analyzes browsing activity across website to establish user profile – https://www.facebook.com/policies/cookies/
    A user can delete these cookies through browser settings.
    Improving Website experienceThese provide functionality to help us deliver a better user experience for our website. For example, cookies help facilitate chats with our sales representatives, allow you to search the website, and deliver the user quickly to their intended website location.1st party and selected third parties as defined below:
    • __cfduid 3rd party cookie – This cookie is strictly necessary for Cloudflare’s security features
    • __hssc Cookie for keeping track of sessions. This is used to determine if we should increment the session number and timestamps in the __hstc cookie. It contains: the domain, viewCount (increments each pageView in a session), session start timestamp. (Expires: 30 min)
    • __hssrc Whenever HubSpot changes the session cookie, this cookie is also set. We set it simply to the value “1”, and use it to determine if the user has restarted their browser. If this cookie does not exist when we manage cookies, we assume it is a new session. (Expires: None. Session cookie)
    • __hstc The main cookie for tracking visitors. It contains: the domain, utk (see below), initial timestamp (first visit), last timestamp (last visit), current timestamp (this visit), and session number (increments for each subsequent session) (Expires: 2 years)
    • hsfirstvisit This cookie used to keep track of a user’s first visit. (Expires: 10 years)
    • hubspotutk This cookie is used for to keep track of a visitor’s identity. This cookie is passed to HubSpot on form submission and used when deduplicating contacts. (Expires: 10 years)
    • wordpress_ WordPress cookie for a logged in user.
    • wordpress_logged_in_ WordPress cookie for a logged in user.
    • wp-settings- WordPress also sets a few wp-settings-[UID] cookies. The number on the end is your individual user ID from the users database table. This is used to customize your view of admin interface, and possibly also the main site interface.
    • wp-settings-time- WordPress also sets a few wp-settings-{time}-[UID] cookies. The number on the end is your individual user ID from the users database table. This is used to customize your view of admin interface, and possibly also the main site interface.
    • __cfduid 3rd party cookie – This cookie is strictly necessary for Cloudflare’s security features
    A user can delete these cookies through browser settings.
    LAST UPDATE: 24.01.2018, LONDON
    Approve
    Refuse
    Welcome
    We use cookies to ensure that we give you the best experience on our website. Before you continue browsing you must approve or refuse our cookie policy.
    Approve
    Refuse
    Cookie Policy