Sunday Feb 5

Archive for July, 2009

Jul
18/09
WordZe API Python Script
Last Updated on Wednesday, 14 April 2010 09:56
Written by Cody Snider
Saturday, July 18th, 2009

Can be run from the command line or in another application. Built for Python 2.4 with pyCURL

View Code PYTHON
import sys, pycurl, re, time, string, urllib
from datetime import date
import xml.dom.minidom
 
class WordZe:
 
	def __init__(self, key='ADD YOUR KEY HERE'):
		self.apiKey = key
		self.caretakerObj = WordZeCaretaker()
		self.userAgent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; es-ES; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729)'
 
	def singleKeywordLookup(self, keyList = []):
		if len(keyList) == 0:
			raise Error('You need to pass a list to the singleKeywordLookup to perform a request.')
		else:
			# TODO: DB CHECK FOR VALUE PULLED WITHIN LAST 30 DAYS
			keyString = string.join(keyList, ',')
 
			requestObj = pycurl.Curl()
 
			requestObj.setopt(pycurl.USERAGENT, self.userAgent)
			requestObj.setopt(pycurl.FOLLOWLOCATION, 1)
			requestObj.setopt(pycurl.WRITEFUNCTION, self.caretakerObj.remotecallback)
			requestObj.setopt(pycurl.HTTPGET, 1)
 
			keyString = str(keyString).replace(' ','+')
			requestObj.setopt(pycurl.URL, str('http://api.wordze.com/KeywordSingle?ApiKey=' + str(self.apiKey) + '&Query=' + str(keyString)))
			requestObj.perform()
			requestObj.close()
 
			return self.caretakerObj.getDict()
 
class WordZeCaretaker:
 
	def __init__(self):
		self.contents = ''
 
	def getDict(self):
		docMod = xml.dom.minidom.parseString(self.contents)
		return self.handleKeywords(docMod)
 
	def handleKeywords(self, docMod):
		returnDict = []
		keywords = docMod.getElementsByTagName("Keyword")
		for keyword in keywords:
			keyDict = {
			    'keyword':self.getText(keyword.childNodes),
			    'count':int(keyword.attributes['Count'].value),
			    'estimated':int(keyword.attributes['Estimated'].value)
			    }
			returnDict.append(keyDict)
		# TODO: DB INSERT
 
		return returnDict
 
	def getText(self,nodelist):
		rc = ""
		for node in nodelist:
			if node.nodeType == node.TEXT_NODE:
				rc = rc + node.data
		return rc
 
	def remotecallback(self, buf):
		self.contents = self.contents + buf
 
if __name__ == '__main__':
	lookupObj = WordZe()
	keywords = raw_input('Comma sep, no spaces list of terms: ')
	termList = str(keywords).split(',')
	cleanList = []
	for term in termList:
		cleanList.append(str(term))
	lookupObj.singleKeywordLookup(cleanList)
Posted under Python, SEO  |  Comments  2 Comments
Jul
04/09
CrunchPad
Last Updated on Saturday, 4 July 2009 10:42
Written by Cody Snider
Saturday, July 4th, 2009

If you’ve carried on a conversation with me regarding modern laptops, you’d know I LOVE netbooks and the underlying shift in the way computers are being built because of them.

Since the dawn of the personal computer as a reasonably priced appliance in the home, everything has been fueled by faster/bigger/more powerful. This has worked out really well for myself and other enthusiasts because it meant the latest-and-greatest would have to be competitively priced. But who needs a system with 4 cores for email, web and office applications (especially since most of this is freely available as an online service). Thanks, Google!

Well, the coolest little computer to be announced so far that really seems to tackle the need for a machine to elegantly do what is needed and nothing more is the CrunchPad. Check it out. Digg it. StumbleUpon it. We need more of this (let’s not even get started on the fact that keyboards and mice are still the main way to interact with our machines).

Posted under Hardware, Innovation, Rants  |  Comments  No Comments