Get Google Page Ranking in Python

Get Google Page Ranking in Python

In this tutorial, we will learn how to Get Google Page Ranking in Python using the google library. Using this method, you can easily get the ranking of any website in google search results for any keyword. Using this python program, you can save a lot of time if you want to manually try the same, you will need to click many times and will need to search for the website manually which is a headache task.

We will need google library, to install it, type the below command in your terminal:

pip install google

Everything is pretty simple, we need to import the library and need to give some parameters like query and website name. We have explained everything using comments, let’s start:-

Code to Get Google Page Ranking in Python:

# importing library
from googlesearch import search

# enter website name
website = input('Enter website: ')
# enter query
query = input('Enter query: ')
# initilazing index=0
index = 0

# search will return an object containing
# all url from google search results
# here, tid is top level domain, 
# stop means how many search results you want
# stop=100 means we will get top 100 results from google
for i in search(query, tld="com", num=10, stop=100, pause=2):
    # checking website in results
    if website in i:
        # printing index of website and url
        print(index+1, i)
    index += 1

Output1:

Enter website: copyassignment
Enter query: python projects for resume
Website rank is: 1
URL is: https://copyassignment.com/20-python-projects-for-resume/

Check the below screenshot as proof:

Output 1 to Get Google Page Ranking in Python

Output2:

Enter website: copyassignment
Enter query: python oop projects
Website rank is: 1
URL is: https://copyassignment.com/python-oop-projects-source-code-and-example/

Check the below screenshot as proof:

Output 2 to Get Google Page Ranking in Python

There are some other ways to check the ranking of a website in google search results using Python, we are giving links to the best articles.


Also Read:

Share:

Author: Harry

Hello friends, thanks for visiting my website. I am a Python programmer. I, with some other members, write blogs on this website based on Python and Programming. We are still in the growing phase that's why the website design is not so good and there are many other things that need to be corrected in this website but I hope all these things will happen someday. But, till then we will not stop ourselves from uploading more amazing articles. If you want to join us or have any queries, you can mail me at admin@copyassignment.com Thank you