<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Coding With Cody &#187; Python</title>
	<atom:link href="http://www.codingwithcody.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codingwithcody.com</link>
	<description>write compile run repeat</description>
	<lastBuildDate>Tue, 10 Jan 2012 21:52:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Python 2.7 on CentOS 5.6</title>
		<link>http://www.codingwithcody.com/2012/01/python-2-7-on-centos-5-6/</link>
		<comments>http://www.codingwithcody.com/2012/01/python-2-7-on-centos-5-6/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 03:55:28 +0000</pubDate>
		<dc:creator>Cody Snider</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Servers]]></category>

		<guid isPermaLink="false">http://www.codingwithcody.com/?p=151</guid>
		<description><![CDATA[Here you have it, folks. A shell script that will handle all the ugliness associated with installing Python 2.7 on CentOS 5.6 (and probably CentOS 5.7, too). Use the following command in your shell (the easy way): wget -q -O http://codingwithcody.com/downloads/python_27_on_centos_56/install.sh &#124; sh Alternately, you can download and run it manually: Download install.sh Here are [...]]]></description>
			<content:encoded><![CDATA[<p>Here you have it, folks. A shell script that will handle all the ugliness associated with installing Python 2.7 on CentOS 5.6 (and probably CentOS 5.7, too).</p>
<p>Use the following command in your shell (the easy way):</p>
<blockquote><p>wget -q -O http://codingwithcody.com/downloads/python_27_on_centos_56/install.sh | sh</p></blockquote>
<p>Alternately, you can download and run it manually: <a title="Installation shell script for Python 2.7 on CentOS 5.6" href="http://www.codingwithcody.com/downloads/python_27_on_centos_56/install.sh">Download install.sh</a></p>
<p>Here are the tarballs used just in case the servers hosting them go down and you&#8217;re eager to get Python 2.7 working:</p>
<ul>
<li><a href="http://www.codingwithcody.com/downloads/python_27_on_centos_56/sqlite-amalgamation-3.7.3.tar.gz">sqlite-amalgamation-3.7.3.tar.gz</a></li>
<li><a href="http://www.codingwithcody.com/downloads/python_27_on_centos_56/Python-2.7.1.tgz">Python-2.7.1.tgz</a></li>
<li><a href="http://www.codingwithcody.com/downloads/python_27_on_centos_56/setuptools-0.6c11-py2.7.egg">setuptools-0.6c11-py2.7.egg</a></li>
</ul>
<p>And, just FYI, here&#8217;s the contents of install.sh:</p>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p151code2'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p1512"><td class="code" id="p151code2"><pre class="bash" style="font-family:monospace;">yum <span style="color: #660033;">-y</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">gcc</span> gdbm-devel readline-devel ncurses-devel zlib-devel bzip2-devel sqlite-devel db4-devel openssl-devel tk-devel bluez-libs-devel <span style="color: #c20cb9; font-weight: bold;">make</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>sqlite.org<span style="color: #000000; font-weight: bold;">/</span>sqlite-amalgamation-3.7.3.tar.gz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xfz sqlite-amalgamation-3.7.3.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> sqlite-3.7.3<span style="color: #000000; font-weight: bold;">/</span>
.<span style="color: #000000; font-weight: bold;">/</span>configure
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.python.org<span style="color: #000000; font-weight: bold;">/</span>ftp<span style="color: #000000; font-weight: bold;">/</span>python<span style="color: #000000; font-weight: bold;">/</span>2.7.1<span style="color: #000000; font-weight: bold;">/</span>Python-2.7.1.tgz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvfz Python-2.7.1.tgz
<span style="color: #7a0874; font-weight: bold;">cd</span> Python-2.7.1
.<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python2.7.1 <span style="color: #660033;">--with-threads</span> <span style="color: #660033;">--enable-shared</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ld.so.conf.d<span style="color: #000000; font-weight: bold;">/</span>opt-python2.7.1.conf
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;/opt/python2.7.1/lib/&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ld.so.conf.d<span style="color: #000000; font-weight: bold;">/</span>opt-python2.7.1.conf
ldconfig
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-sf</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python2.7.1<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python2.7
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>pypi.python.org<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2.7</span><span style="color: #000000; font-weight: bold;">/</span>s<span style="color: #000000; font-weight: bold;">/</span>setuptools<span style="color: #000000; font-weight: bold;">/</span>setuptools-0.6c11-py2.7.egg
<span style="color: #c20cb9; font-weight: bold;">sh</span> setuptools-0.6c11-py2.7.egg <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python2.7.1
&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python2.7.1<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>easy_install pip
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-sf</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python2.7.1<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pip <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pip
&nbsp;
pip <span style="color: #c20cb9; font-weight: bold;">install</span> virtualenv
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-sf</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>python2.7.1<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>virtualenv <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>virtualenv
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python-backup
<span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python2.7 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>python</pre></td></tr></table></div>

<p>Any improvements are more than welcome. Enjoy and happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingwithcody.com/2012/01/python-2-7-on-centos-5-6/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Generate Random IP with Python</title>
		<link>http://www.codingwithcody.com/2010/05/generate-random-ip-with-python/</link>
		<comments>http://www.codingwithcody.com/2010/05/generate-random-ip-with-python/#comments</comments>
		<pubDate>Mon, 17 May 2010 18:09:13 +0000</pubDate>
		<dc:creator>Cody Snider</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://codingwithcody.com/?p=55</guid>
		<description><![CDATA[In need of an IP address on-the-fly that appears to be valid? Try this: View Code PYTHONfrom random import randrange &#160; def generateIP&#40;&#41;: blockOne = randrange&#40;0, 255, 1&#41; blockTwo = randrange&#40;0, 255, 1&#41; blockThree = randrange&#40;0, 255, 1&#41; blockFour = randrange&#40;0, 255, 1&#41; print 'Random IP: ' + str&#40;blockOne&#41; + '.' + str&#40;blockTwo&#41; + '.' [...]]]></description>
			<content:encoded><![CDATA[<p>In need of an IP address on-the-fly that appears to be valid? Try this:</p>
<blockquote>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p55code5'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p555"><td class="code" id="p55code5"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">random</span> <span style="color: #ff7700;font-weight:bold;">import</span> randrange
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> generateIP<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    blockOne = randrange<span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">255</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
    blockTwo = randrange<span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">255</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
    blockThree = randrange<span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">255</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
    blockFour = randrange<span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">255</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Random IP: '</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>blockOne<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">'.'</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>blockTwo<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">'.'</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>blockThree<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">'.'</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>blockFour<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> blockOne == <span style="color: #ff4500;">10</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.__generateRandomIP__<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">elif</span> blockOne == <span style="color: #ff4500;">172</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.__generateRandomIP__<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">elif</span> blockOne == <span style="color: #ff4500;">192</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.__generateRandomIP__<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>blockOne<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">'.'</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>blockTwo<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">'.'</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>blockThree<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">'.'</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>blockFour<span style="color: black;">&#41;</span></pre></td></tr></table></div>

</blockquote>
<p>We&#8217;re skipping 10.x.x.x, 172.x.x.x and 192.x.x.x due to the fact that these are reserved address. <a href="http://www.faqs.org/rfcs/rfc1918.html" rel="nofollow">RFC 1918</a></p>
<p><strong>Version 2:</strong></p>
<p>An elegant solution to serve the purpose of generating a random IP provided by <a href="http://spareclockcycles.org/">Ben</a> (explanation of changes listed in the comments below):</p>
<blockquote>

<div class="wp_codebox_msgheader"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p55code6'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p556"><td class="code" id="p55code6"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">random</span> <span style="color: #ff7700;font-weight:bold;">import</span> randrange
<span style="color: #ff7700;font-weight:bold;">if</span> __name__==<span style="color: #483d8b;">&quot;__main__&quot;</span>:
    not_valid = <span style="color: black;">&#91;</span><span style="color: #ff4500;">10</span>,<span style="color: #ff4500;">127</span>,<span style="color: #ff4500;">169</span>,<span style="color: #ff4500;">172</span>,<span style="color: #ff4500;">192</span><span style="color: black;">&#93;</span>
&nbsp;
    first = randrange<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">256</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">while</span> first <span style="color: #ff7700;font-weight:bold;">in</span> not_valid:
    first = randrange<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">256</span><span style="color: black;">&#41;</span>
&nbsp;
    ip = <span style="color: #483d8b;">&quot;.&quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #008000;">str</span><span style="color: black;">&#40;</span>first<span style="color: black;">&#41;</span>,<span style="color: #008000;">str</span><span style="color: black;">&#40;</span>randrange<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">256</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>,
    <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>randrange<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">256</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>,<span style="color: #008000;">str</span><span style="color: black;">&#40;</span>randrange<span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #ff4500;">256</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> ip</pre></td></tr></table></div>

</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.codingwithcody.com/2010/05/generate-random-ip-with-python/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WordZe API Python Script</title>
		<link>http://www.codingwithcody.com/2009/07/wordze-api-python-script/</link>
		<comments>http://www.codingwithcody.com/2009/07/wordze-api-python-script/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 00:04:49 +0000</pubDate>
		<dc:creator>Cody Snider</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://codingwithcody.com/?p=34</guid>
		<description><![CDATA[Can be run from the command line or in another application. Built for Python 2.4 with pyCURL View Code PYTHONimport sys, pycurl, re, time, string, urllib from datetime import date import xml.dom.minidom &#160; class WordZe: &#160; def __init__&#40;self, key='ADD YOUR KEY HERE'&#41;: self.apiKey = key self.caretakerObj = WordZeCaretaker&#40;&#41; self.userAgent = 'Mozilla/5.0 (Windows; U; Windows NT [...]]]></description>
			<content:encoded><![CDATA[<p>Can be run from the command line or in another application. Built for Python 2.4 with pyCURL</p>
<blockquote>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p34code8'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p348"><td class="code" id="p34code8"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>, pycurl, <span style="color: #dc143c;">re</span>, <span style="color: #dc143c;">time</span>, <span style="color: #dc143c;">string</span>, <span style="color: #dc143c;">urllib</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">datetime</span> <span style="color: #ff7700;font-weight:bold;">import</span> date
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">xml</span>.<span style="color: black;">dom</span>.<span style="color: black;">minidom</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> WordZe:
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, key=<span style="color: #483d8b;">'ADD YOUR KEY HERE'</span><span style="color: black;">&#41;</span>:
		<span style="color: #008000;">self</span>.<span style="color: black;">apiKey</span> = key
		<span style="color: #008000;">self</span>.<span style="color: black;">caretakerObj</span> = WordZeCaretaker<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
		<span style="color: #008000;">self</span>.<span style="color: black;">userAgent</span> = <span style="color: #483d8b;">'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)'</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">def</span> singleKeywordLookup<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, keyList = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>:
		<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>keyList<span style="color: black;">&#41;</span> == <span style="color: #ff4500;">0</span>:
			<span style="color: #ff7700;font-weight:bold;">raise</span> Error<span style="color: black;">&#40;</span><span style="color: #483d8b;">'You need to pass a list to the singleKeywordLookup to perform a request.'</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">else</span>:
			<span style="color: #808080; font-style: italic;"># TODO: DB CHECK FOR VALUE PULLED WITHIN LAST 30 DAYS</span>
			keyString = <span style="color: #dc143c;">string</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>keyList, <span style="color: #483d8b;">','</span><span style="color: black;">&#41;</span>
&nbsp;
			requestObj = pycurl.<span style="color: black;">Curl</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
			requestObj.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">USERAGENT</span>, <span style="color: #008000;">self</span>.<span style="color: black;">userAgent</span><span style="color: black;">&#41;</span>
			requestObj.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">FOLLOWLOCATION</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
			requestObj.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">WRITEFUNCTION</span>, <span style="color: #008000;">self</span>.<span style="color: black;">caretakerObj</span>.<span style="color: black;">remotecallback</span><span style="color: black;">&#41;</span>
			requestObj.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">HTTPGET</span>, <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
			keyString = <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>keyString<span style="color: black;">&#41;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">' '</span>,<span style="color: #483d8b;">'+'</span><span style="color: black;">&#41;</span>
			requestObj.<span style="color: black;">setopt</span><span style="color: black;">&#40;</span>pycurl.<span style="color: black;">URL</span>, <span style="color: #008000;">str</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'http://api.wordze.com/KeywordSingle?ApiKey='</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">apiKey</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">'&amp;amp;Query='</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>keyString<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
			requestObj.<span style="color: black;">perform</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
			requestObj.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
			<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">caretakerObj</span>.<span style="color: black;">getDict</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> WordZeCaretaker:
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
		<span style="color: #008000;">self</span>.<span style="color: black;">contents</span> = <span style="color: #483d8b;">''</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">def</span> getDict<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
		docMod = <span style="color: #dc143c;">xml</span>.<span style="color: black;">dom</span>.<span style="color: black;">minidom</span>.<span style="color: black;">parseString</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">contents</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">handleKeywords</span><span style="color: black;">&#40;</span>docMod<span style="color: black;">&#41;</span>
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">def</span> handleKeywords<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, docMod<span style="color: black;">&#41;</span>:
		returnDict = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
		keywords = docMod.<span style="color: black;">getElementsByTagName</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Keyword&quot;</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #dc143c;">keyword</span> <span style="color: #ff7700;font-weight:bold;">in</span> keywords:
			keyDict = <span style="color: black;">&#123;</span>
			    <span style="color: #483d8b;">'keyword'</span>:<span style="color: #008000;">self</span>.<span style="color: black;">getText</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">keyword</span>.<span style="color: black;">childNodes</span><span style="color: black;">&#41;</span>,
			    <span style="color: #483d8b;">'count'</span>:<span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">keyword</span>.<span style="color: black;">attributes</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'Count'</span><span style="color: black;">&#93;</span>.<span style="color: black;">value</span><span style="color: black;">&#41;</span>,
			    <span style="color: #483d8b;">'estimated'</span>:<span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">keyword</span>.<span style="color: black;">attributes</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'Estimated'</span><span style="color: black;">&#93;</span>.<span style="color: black;">value</span><span style="color: black;">&#41;</span>
			    <span style="color: black;">&#125;</span>
			returnDict.<span style="color: black;">append</span><span style="color: black;">&#40;</span>keyDict<span style="color: black;">&#41;</span>
		<span style="color: #808080; font-style: italic;"># TODO: DB INSERT</span>
&nbsp;
		<span style="color: #ff7700;font-weight:bold;">return</span> returnDict
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">def</span> getText<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,nodelist<span style="color: black;">&#41;</span>:
		rc = <span style="color: #483d8b;">&quot;&quot;</span>
		<span style="color: #ff7700;font-weight:bold;">for</span> node <span style="color: #ff7700;font-weight:bold;">in</span> nodelist:
			<span style="color: #ff7700;font-weight:bold;">if</span> node.<span style="color: black;">nodeType</span> == node.<span style="color: black;">TEXT_NODE</span>:
				rc = rc + node.<span style="color: black;">data</span>
		<span style="color: #ff7700;font-weight:bold;">return</span> rc
&nbsp;
	<span style="color: #ff7700;font-weight:bold;">def</span> remotecallback<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, buf<span style="color: black;">&#41;</span>:
		<span style="color: #008000;">self</span>.<span style="color: black;">contents</span> = <span style="color: #008000;">self</span>.<span style="color: black;">contents</span> + buf
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
	lookupObj = WordZe<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	keywords = <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Comma sep, no spaces list of terms: '</span><span style="color: black;">&#41;</span>
	termList = <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>keywords<span style="color: black;">&#41;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">','</span><span style="color: black;">&#41;</span>
	cleanList = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
	<span style="color: #ff7700;font-weight:bold;">for</span> term <span style="color: #ff7700;font-weight:bold;">in</span> termList:
		cleanList.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">str</span><span style="color: black;">&#40;</span>term<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
	lookupObj.<span style="color: black;">singleKeywordLookup</span><span style="color: black;">&#40;</span>cleanList<span style="color: black;">&#41;</span></pre></td></tr></table></div>

</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.codingwithcody.com/2009/07/wordze-api-python-script/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

