google search rankings and trends api

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

I'm looking to find an api/program/interface to get the following information.

  1. a term(s) overall popularity - ala google trends
  2. how a website shows up rank wise in for said term(s) - ala googlesearchpositionfinder and how many websites have the term(s) - standard google, e.g. Searching for foobar and urban dictionary shows up at position 5 of 9,000,000

I would like to see the amount of times a particular search term was used and its /weekly/monthly/yearly popularity breakdown along with its rank in a particular page.

I've found googlesearchpositionfinder.com and google.com/trends but i have 5000 terms to search for by hand is not happening. I've also found www.juiceanalytics.com/openjuice/programmatic-google-trends-api but it doesn't allow me to do a break down for a period of 2 years.

Basically i'm trying to create a ranking of search phrases, the weeks(period) they were more popular and how a particular site(e.g urban dictionary) showed up in googles search rankings for the terms. See above (1-2)

Also this doesn't have to be in python this is just what I've found to build with...

Latest edit: Both answers below helped.

I ended up using curl against google directly and then parsing the results with a c# program.

profilepic.png
manpreet 2 years ago

 

Google trends does not allow a search on a range of two years, but one year at time.
Using pyGTrends.py you could do:

from import pyGTrends
from csv import DictReader
r = pyGTrends(username, password)
r.download_report(('stackoverflow'), date='2009')
export1 = DictReader(r.csv().split('\n'))
r.download_report(('stackoverflow'), date='2010')
export2 = DictReader(r.csv().split('\n'))

then you could join export1 and export2 to suit your needs.

OR even better

You could download the report without date filter and do the dirty job with Python.
Have a look to the following script, arrange date_MIN\date_MAX as you need.

from pyGTrends import pyGTrends
import csv
import datetime
date_MIN ='2007/01/01'
date_MAX ='2009/03/01'
r = pyGTrends('username','password')
r.download_report(('stackoverflow'))
csv_reader = csv.reader(r.csv().split('\n'))
with open('gtrends_report.csv', 'w') as csv_out:
    csv_writer = csv.writer(csv_out)
    for count,row in enumerate(csv_reader):
        if count == 0:
            csv_writer.writerow(row)
        else:
            date = datetime.datetime.strptime(row[0], "%b %d %Y")
            if  datetime.datetime.strptime(date_MIN, "%Y/%m/%d") <= date <= datetime.datetime.strptime(date_MAX, "%Y/%m/%d"):
                 csv_writer.writerow(row)

0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.