Finding inlink information from Yahoo! in Python

linkbuildinglu7Inlinks (aka backlinks) are an important aspect of your SEO strategy. They are the ways that people will find your website and they are an indicator to search engines that your website is important and should rank well. So it is important to keep an eye on this statistic for your website. There is a saying: “you can’t manage what you can’t measure” which applies. If you want your website to rank well you need to manage your inlinks and so you need to measure them.

This script requires a Yahoo! AppID because it uses the REST API for Yahoo! Site Explorer rather than any scraping of pages which you can get by going to the Yahoo! Developer Network.

The script simply returns the total number of results but you could easily extend this to print out all your inlinks. I will be using this to track my inlink count over time by running it every day and storing the result in a database.

Example Usage:

$ python yahooInlinks.py http://www.halotis.com
checking http://www.halotis.com
937

Here’s the Python Code:

#!/usr/bin/env python 
# -*- coding: utf-8 -*-
# (C) 2009 HalOtis Marketing
# written by Matt Warren
# http://halotis.com/
 
import urllib2, sys, urllib
 
try:
   import json
except:
   import simplejson as json # http://undefined.org/python/#simplejson
 
YAHOO_APP_ID='YOUR API KEY'
 
def yahoo_inlinks_count(query):
    if not query.startswith('http://') raise Exception('site must start with "http://"')
 
    request = 'http://search.yahooapis.com/SiteExplorerService/V1/inlinkData?appid=' + YAHOO_APP_ID + '&query=' + urllib.quote_plus(query) + '&output=json&results=0'
 
    try:
    	results = json.load(urllib2.urlopen(request))
    except:
    	raise Exception("Web services request failed")
    	sys.exit()
 
    return results['ResultSet']['totalResultsAvailable']
 
if __name__=='__main__':
    print 'checking', sys.argv[1]
    print yahoo_inlinks_count(sys.argv[1])

Technorati Tags: , , , , , ,



RSS feed | Trackback URI

5 Comments »

2009-08-16 06:30:10

[...] View original here:  Finding inlink information from Yahoo! in Python [...]

 
2009-08-16 09:17:27

[...] Finding inlink report from Yahoo! in Python | HalOtis Marketing [...]

 
Comment by Dip
2010-02-17 15:41:18

How mutch request make do? Before ban.

 
Comment by dsf
2010-05-29 14:19:19

thanks for these freat tips.
an easier method to gather yahoo data (and other) is by using http://ministatus.com. one could also download the gathered results in pdf form for later usage.

 
Trackback by Niche Sites
2011-08-15 16:34:25

Niche Sites…

Finding inlink information from Yahoo! in Python | HalOtis…

 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight=""> in your comment.