<?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>A Little Off &#187; API</title>
	<atom:link href="http://www.bemasher.net/archives/tag/api/feed" rel="self" type="application/rss+xml" />
	<link>http://www.bemasher.net</link>
	<description>Code, Computers, Photography and Guns</description>
	<lastBuildDate>Mon, 21 Nov 2011 06:38:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>System Memory Analysis</title>
		<link>http://www.bemasher.net/archives/1055?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=system-memory-analysis</link>
		<comments>http://www.bemasher.net/archives/1055#comments</comments>
		<pubDate>Wed, 01 Jun 2011 02:55:50 +0000</pubDate>
		<dc:creator>bemasher</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Analysis]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[Memory]]></category>
		<category><![CDATA[Newegg]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[RAM]]></category>
		<category><![CDATA[System]]></category>

		<guid isPermaLink="false">http://www.bemasher.net/?p=1055</guid>
		<description><![CDATA[Choosing the best RAM for your system can be difficult, as there are a lot of things to consider. Doing comparisons by hand can net you some pretty decent results but picking the best price per capacity per ... can get fairly complicated if you're doing it by hand. A while ago you may remember [...]]]></description>
			<content:encoded><![CDATA[<p>Choosing the best RAM for your system can be difficult, as there are a lot of things to consider. Doing comparisons by hand can net you some pretty decent results but picking the best price per capacity per ... can get fairly complicated if you're doing it by hand.</p>
<p>A while ago you may remember my SSD analysis script<sup>[<a href="http://www.bemasher.net/archives/1055#footnote_0_1055" id="identifier_0_1055" class="footnote-link footnote-identifier-link" title="Choosing an SSD (A more different S)">1</a>]</sup> that scraped HTML from Newegg to calculate scores for each product to choose the best one. I've also recently discovered that Newegg does indeed have an API<sup>[<a href="http://www.bemasher.net/archives/1055#footnote_1_1055" id="identifier_1_1055" class="footnote-link footnote-identifier-link" title="Newegg&#039;s JSON API">2</a>]</sup> that greatly simplifies this whole process<sup>[<a href="http://www.bemasher.net/archives/1055#footnote_2_1055" id="identifier_2_1055" class="footnote-link footnote-identifier-link" title="Even though it was never intended for that what I&#039;m using it for.">3</a>]</sup>.</p>
<p>Once I had explored Newegg's API enough to get the data I needed I set to work to update the SSD script as well as write a few others for HDD's and system memory as well. Of the scripts I wrote the one for system memory turned out to be particularly useful as it made finding great deals very easy. It also illustrated that popular brands may not always be the best deal.</p>
<p>The first major improvement over the previous scripts was the use of threading to make multiple API requests in parallel which sped things up quite a bit. While Python's threading library doesn't allow for parallelism of the CPU<sup>[<a href="http://www.bemasher.net/archives/1055#footnote_3_1055" id="identifier_3_1055" class="footnote-link footnote-identifier-link" title="Python is crippled in this way due to a global interpreter lock.">4</a>]</sup> it does for file I/O. Below is the class used for grabbing urls throughout the script.</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">threading</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">urllib2</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> json<span style="color: #66cc66;">,</span> <span style="color: #dc143c;">re</span><br />
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">Queue</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">Queue</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">class</span> GetURL<span style="color: black;">&#40;</span><span style="color: #dc143c;">threading</span>.<span style="color: black;">Thread</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &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: #66cc66;">,</span> urlQueue<span style="color: #66cc66;">,</span> jsonQueue<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #dc143c;">threading</span>.<span style="color: black;">Thread</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><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">urlQueue</span> <span style="color: #66cc66;">=</span> urlQueue<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">jsonQueue</span> <span style="color: #66cc66;">=</span> jsonQueue<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> run<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; itemNumber<span style="color: #66cc66;">,</span> url <span style="color: #66cc66;">=</span> <span style="color: #008000;">self</span>.<span style="color: black;">urlQueue</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raw <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>url<span style="color: black;">&#41;</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jsonQueue.<span style="color: black;">put</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>itemNumber<span style="color: #66cc66;">,</span> json.<span style="color: black;">loads</span><span style="color: black;">&#40;</span>raw<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">self</span>.<span style="color: black;">urlQueue</span>.<span style="color: black;">task_done</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>Newegg's API paginates the data as the Android app displays the data directly to the user which means there's no easy way to retrieve all results in one request. So you must make successive calls incrementing the page number until all results for the query have been retrieved.</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">itemSpecURL <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;http://www.ows.newegg.com/Products.egg/{}/Specification&quot;</span><br />
searchURL <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;http://www.ows.newegg.com/Search.egg/Advanced&quot;</span><br />
<br />
itemList <span style="color: #66cc66;">=</span> getItems<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<br />
urlQueue <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">Queue</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
jsonQueue <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">Queue</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
items <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> itemList:<br />
&nbsp; &nbsp; specURL <span style="color: #66cc66;">=</span> itemSpecURL.<span style="color: black;">format</span><span style="color: black;">&#40;</span>item<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;ItemNumber&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; urlQueue.<span style="color: black;">put</span><span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>item<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;ItemNumber&quot;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> specURL<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; items<span style="color: black;">&#91;</span>item<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;ItemNumber&quot;</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> item<br />
&nbsp; &nbsp; <br />
<span style="color: #ff7700;font-weight:bold;">for</span> worker <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; t <span style="color: #66cc66;">=</span> GetURL<span style="color: black;">&#40;</span>urlQueue<span style="color: #66cc66;">,</span> jsonQueue<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; t.<span style="color: black;">setDaemon</span><span style="color: black;">&#40;</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; t.<span style="color: black;">start</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<br />
urlQueue.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>These basic setups are fairly generic and can be used to analyze just about any product from Newegg. Anything beyond this point however is specific to the type of product you're analyzing. This will grab each item's basic data including price as well as it's detailed specifications. I should also note that the parameters passed to the API in <em>getItems</em> is generated using the query builder available in the post about Newegg's API.</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">speed_re <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'DDR<span style="color: #000099; font-weight: bold;">\d</span><span style="color: #000099; font-weight: bold;">\s</span>(<span style="color: #000099; font-weight: bold;">\d</span>+).*'</span><span style="color: black;">&#41;</span><br />
capacity_re <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;(<span style="color: #000099; font-weight: bold;">\d</span>+)GB<span style="color: #000099; font-weight: bold;">\s</span><span style="color: #000099; font-weight: bold;">\(</span>(<span style="color: #000099; font-weight: bold;">\d</span>+)<span style="color: #000099; font-weight: bold;">\s</span>x<span style="color: #000099; font-weight: bold;">\s</span>(<span style="color: #000099; font-weight: bold;">\d</span>+)GB<span style="color: #000099; font-weight: bold;">\)</span>&quot;</span><span style="color: black;">&#41;</span><br />
timing_re <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'(<span style="color: #000099; font-weight: bold;">\d</span>+-<span style="color: #000099; font-weight: bold;">\d</span>+-<span style="color: #000099; font-weight: bold;">\d</span>+-<span style="color: #000099; font-weight: bold;">\d</span>+)'</span><span style="color: black;">&#41;</span><br />
features <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: #483d8b;">'Brand'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'Model'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'ItemNumber'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'Price'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'Speed'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'Capacity'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'Dimms'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'Timing'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'Voltage'</span><span style="color: black;">&#93;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #ff7700;font-weight:bold;">not</span> jsonQueue.<span style="color: black;">empty</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; itemNumber<span style="color: #66cc66;">,</span> specs <span style="color: #66cc66;">=</span> jsonQueue.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; item <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> group <span style="color: #ff7700;font-weight:bold;">in</span> specs<span style="color: black;">&#91;</span><span style="color: #483d8b;">'SpecificationGroupList'</span><span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> pair <span style="color: #ff7700;font-weight:bold;">in</span> group<span style="color: black;">&#91;</span><span style="color: #483d8b;">'SpecificationPairList'</span><span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> pair<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Key'</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">in</span> features:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; item<span style="color: black;">&#91;</span>pair<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Key'</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> pair<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Value'</span><span style="color: black;">&#93;</span>.<span style="color: black;">encode</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'ascii'</span><span style="color: #66cc66;">,</span> errors<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'ignore'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #483d8b;">'Capacity'</span> <span style="color: #ff7700;font-weight:bold;">in</span> item:<br />
&nbsp; &nbsp; &nbsp; &nbsp; capacity <span style="color: #66cc66;">=</span> capacity_re.<span style="color: black;">match</span><span style="color: black;">&#40;</span>item<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Capacity'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> capacity:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; item<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Capacity'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> capacity.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; item<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Dimms'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> capacity.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #483d8b;">'Speed'</span> <span style="color: #ff7700;font-weight:bold;">in</span> item:<br />
&nbsp; &nbsp; &nbsp; &nbsp; speed <span style="color: #66cc66;">=</span> speed_re.<span style="color: black;">match</span><span style="color: black;">&#40;</span>item<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Speed'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> speed:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; item<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Speed'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> speed.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #483d8b;">'Timing'</span> <span style="color: #ff7700;font-weight:bold;">in</span> item:<br />
&nbsp; &nbsp; &nbsp; &nbsp; timing <span style="color: #66cc66;">=</span> timing_re.<span style="color: black;">match</span><span style="color: black;">&#40;</span>item<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Timing'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> timing:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; item<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Timing'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> timing.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><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: #66cc66;">,</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\t</span>'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">continue</span><br />
&nbsp; &nbsp; item<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Price'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> items<span style="color: black;">&#91;</span>itemNumber<span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'FinalPrice'</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; item<span style="color: black;">&#91;</span><span style="color: #483d8b;">'ItemNumber'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> specs<span style="color: black;">&#91;</span><span style="color: #483d8b;">'NeweggItemNumber'</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\t</span>'</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: #008000;">map</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x: item<span style="color: black;">&#91;</span>x<span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> features<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">KeyError</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span><br />
&nbsp; &nbsp; jsonQueue.<span style="color: black;">task_done</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>The basic purpose of the above code is to go through each item and format each feature into usable data<sup>[<a href="http://www.bemasher.net/archives/1055#footnote_4_1055" id="identifier_4_1055" class="footnote-link footnote-identifier-link" title="Or at least the data that we&#039;re interested in using for analysis.">5</a>]</sup>. Once the data has been formatted and printed I continue the rest of the filtering and analysis in Microsoft's Excel.</p>
<p>The equation used to calculate a score for each set of system memory is as follows:</p>
<p><center><img src='http://s0.wp.com/latex.php?latex=%5Cfrac%7B%28%5Ctext%7BCapacity%7D%5Ctimes1024%5E3%29%5Ctimes%5Ctext%7BSpeed%7D%7D%7B%5Ctext%7BPrice%7D%5Ctimes+CL%5Ctimes+T_%7BRCD%7D+%5Ctimes+T_%7BRP%7D+%5Ctimes+T_%7BRAS%7D%7D&#038;bg=ffffff&#038;fg=000&#038;s=0' alt='&#92;frac{(&#92;text{Capacity}&#92;times1024^3)&#92;times&#92;text{Speed}}{&#92;text{Price}&#92;times CL&#92;times T_{RCD} &#92;times T_{RP} &#92;times T_{RAS}}' title='&#92;frac{(&#92;text{Capacity}&#92;times1024^3)&#92;times&#92;text{Speed}}{&#92;text{Price}&#92;times CL&#92;times T_{RCD} &#92;times T_{RP} &#92;times T_{RAS}}' class='latex' /></center></p>
<p>Currently it looks like G.Skill has the best to offer in the DDR3 memory market if you're looking for a quad-channel set for Sandy Bridge's enthusiast hardware due out in the next quarter<sup>[<a href="http://www.bemasher.net/archives/1055#footnote_5_1055" id="identifier_5_1055" class="footnote-link footnote-identifier-link" title="G.SKILL Ripjaws X Series 16GB (4 x 4GB) 1333Mhz">6</a>]</sup>.</p>
<ol class="footnotes"><li id="footnote_0_1055" class="footnote"><a href="http://www.bemasher.net/archives/927">Choosing an SSD (A more different S)</a></li><li id="footnote_1_1055" class="footnote"><a href="http://www.bemasher.net/archives/1002">Newegg's JSON API</a></li><li id="footnote_2_1055" class="footnote">Even though it was never intended for that what I'm using it for.</li><li id="footnote_3_1055" class="footnote">Python is crippled in this way due to a global interpreter lock.</li><li id="footnote_4_1055" class="footnote">Or at least the data that we're interested in using for analysis.</li><li id="footnote_5_1055" class="footnote"><a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16820231442">G.SKILL Ripjaws X Series 16GB (4 x 4GB) 1333Mhz</a></li></ol>]]></content:encoded>
			<wfw:commentRss>http://www.bemasher.net/archives/1055/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Newegg&#8217;s JSON API</title>
		<link>http://www.bemasher.net/archives/1002?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=neweggs-json-quasi-api</link>
		<comments>http://www.bemasher.net/archives/1002#comments</comments>
		<pubDate>Thu, 17 Mar 2011 05:11:22 +0000</pubDate>
		<dc:creator>bemasher</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[CherryPy]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[lxml]]></category>
		<category><![CDATA[Newegg]]></category>
		<category><![CDATA[Product List]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Script]]></category>

		<guid isPermaLink="false">http://www.bemasher.net/?p=1002</guid>
		<description><![CDATA[For the longest time I've wanted access to Newegg's product list. For me they've been one of the better and more structured websites for buying computer hardware. So naturally they're usually my first choice when it comes to finding a good deal on a particular piece of hardware. They're also rather useful for seeing what's [...]]]></description>
			<content:encoded><![CDATA[<p>For the longest time I've wanted access to Newegg's product list. For me they've been one of the better and more structured websites for buying computer hardware. So naturally they're usually my first choice when it comes to finding a good deal on a particular piece of hardware. They're also rather useful for seeing what's out there since their product catalog is fairly complete.</p>
<p>A while back I had started wanting to sort through items to heuristically pick the best deal based on a number of features Newegg generally provides for each item. This method works pretty well on SSD's and system memory. But until a recent discovery I was limited to scraping Newegg's website in order to get any kind of information from them. If you've ever tried this sort of thing you know that it is messy and generally a bad idea because every single time Newegg changes the structure of their website or any minute detail this will almost always break your scraping script.</p>
<p>The discovery came in the form of a mobile application for Android<sup>[<a href="http://www.bemasher.net/archives/1002#footnote_0_1002" id="identifier_0_1002" class="footnote-link footnote-identifier-link" title="And iOS devices I assume as well.">1</a>]</sup>. The mobile app lets you browse their website in a clean and fast manner. But what got me thinking is that unlike some other mobile applications out there that are just application wrappers for the mobile version of their websites this one operates directly through the native GUI. Now this is where it got interesting. I knew that if Newegg had written the app to use the native GUI then they had to be providing the data to it somehow and I knew it had to be more structured than HTML scraping like what I've been doing<sup>[<a href="http://www.bemasher.net/archives/1002#footnote_1_1002" id="identifier_1_1002" class="footnote-link footnote-identifier-link" title="Because lets face it, that would be stupid.">2</a>]</sup>. You have no idea how happy I was to discover that I was right.</p>
<p>First thing I did was connect my Droid 2 Global to my home network via WiFi in order to sniff some of the traffic going to and from the mobile app. This was accomplished by mounting a CIFS drive from my Windows 7 desktop to my router running Tomato based firmware. The share had a binary for TCPDump which I then used to sniff for traffic originating or going to my phone's IP address. After setting this up and performing all of the basic operations I would need in order to "reverse engineer" the data source I got to work on filtering the important bits.</p>
<p>In WireShark I immediately discovered that they had a sub-domain they were using for these operations. All of the web requests that weren't images or for customer metrics and tracking went to this host:</p>
<p><a href="http://www.ows.newegg.com/">http://www.ows.newegg.com/</a></p>
<p>Because this API is structured more or less the same as navigating their site and the identifiers are different I decided to start with writing a query builder. Basically the purpose was to allow me to browse to the particular category I was interested in analyzing and filter it down to just a few simple requirements to simplify the analysis.</p>
<p>The first major entry point in the process of browsing to what you're interested in pulling is:</p>
<p><a href="http://www.ows.newegg.com/Stores.egg/Menus">http://www.ows.newegg.com/Stores.egg/Menus</a></p>
<p>This takes no parameters and provides the main menu:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreDepa&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;ComputerHardware&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ShowSeeAllDeals&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Computer Hardware&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreDepa&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;PCNotebook&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ShowSeeAllDeals&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;PCs &amp;amp; Laptops&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreDepa&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Electronics&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ShowSeeAllDeals&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Electronics&quot;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; ...</div></td></tr></tbody></table></div>
<p>Once you've selected a store to browse the next uri is:</p>
<p><a href="http://www.ows.newegg.com/Stores.egg/Categories/{StoreID}">http://www.ows.newegg.com/Stores.egg/Categories/{StoreID}</a></p>
<p>The only parameter it takes is StoreID which you'll find in the first query. This will return all of the categories within a store. I haven't really explored this very much as I'm only really interested in browsing system memory and SSD's. Using the Computer Hardware store the output is as follows:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Backup Devices &amp;amp; Media&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;NodeId&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">6642</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ShowSeeAllDeals&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryType&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">2</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Barebone / Mini Computers&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;NodeId&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">6668</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ShowSeeAllDeals&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryType&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">3</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;CD / DVD Burners &amp;amp; Media&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;NodeId&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">6646</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ShowSeeAllDeals&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryType&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">10</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; ...</div></td></tr></tbody></table></div>
<p>StoreID is included from the parameters of the request. I'm not exactly sure how to describe the purpose of NodeID but it appears to be a distinguishing feature of a category or subcategory. CategoryID is used for filtering results down to a specific category and can be either a root category or a subcategory. CategoryType determines whether CategoryID is a root category or if it contains subcategories. A value of 1 for CategoryType indicates that it is the root category.</p>
<p>Now depending on CategoryType you either move straight to the search query or onto a navigation query. The navigation query is used if there are subcategories:</p>
<p><a href="http://www.ows.newegg.com/Stores.egg/Navigation/{StoreID}/{CategoryID}/{NodeID}">http://www.ows.newegg.com/Stores.egg/Navigation/{StoreID}/{CategoryID}/{NodeID}</a></p>
<p>This query takes StoreID, CategoryID and NodeID, which you can get from the category listing of a particular store. It will return a subcategory list. Below is the subcategory listing for the memory category.</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Desktop Memory&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;NodeId&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">7611</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ShowSeeAllDeals&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryType&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">147</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Flash Memory&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;NodeId&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">8038</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ShowSeeAllDeals&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryType&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">68</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Laptop Memory&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;NodeId&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">7609</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ShowSeeAllDeals&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryType&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">381</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; ...</div></td></tr></tbody></table></div>
<p>From here you will go to the search query<sup>[<a href="http://www.bemasher.net/archives/1002#footnote_2_1002" id="identifier_2_1002" class="footnote-link footnote-identifier-link" title="... or get to the search query from selecting a root category in the main category listing for a store">3</a>]</sup>. At this point it does get a little tricky as the parameters for the query are no longer sent via GET they are instead sent using POST<sup>[<a href="http://www.bemasher.net/archives/1002#footnote_3_1002" id="identifier_3_1002" class="footnote-link footnote-identifier-link" title="At least this is the method used by the mobile app.">4</a>]</sup> which basically will require a programmatic method for making a search query. The search query given a category, store and node will list quite a lot of things. The first thing in the list is search filtering parameters, these will allow you to limit the products shown in the listing.</p>
<p>Data being posted is necessary to receive a non-404 response from the server, if you really wanted to you could just send an empty dictionary as this would just query newegg's entire product list. Any of the query options can be omitted, integer values may be omitted by substituting their value with -1.</p>
<p>The parameters you should concern yourself with are as follows along with the URL the data should be posted in JSON format to:</p>
<p><a href="http://www.ows.newegg.com/Search.egg/Advanced">http://www.ows.newegg.com/Search.egg/Advanced</a></p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">data <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;SubCategoryId&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">147</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;NValue&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreDepaId&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;NodeId&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">7611</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;BrandId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;PageNumber&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryId&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">17</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>NValue is a space separated list of NValues from the search parameters. Mind you, you cannot filter against more than one item in any category of search filters. For example in system memory you can't select <strong>DDR3 1333 (PC3 10600)</strong>, <strong>DDR3 1333 (PC3 10660)</strong> and <strong>DDR3 1333 (PC3 10666)</strong>. The query will return an unsucessful search result. The rest of the parameters are fairly self-explanatory.</p>
<p>The result returned will contain the following elements: RelatedLinkList, CoremetricsInfo, NavigationContentList, PaginationInfo, ProductListItems. CoremetricsInfo and RelatedLinkList can usually be ignored, the elements we're interested in are the NavigationContentList which is a list of search parameters//filters you can apply to the search. PaginationInfo describes how many elements were returned, what page we're on and how many elements there are per page. Last but not least the ProductListItems which provides a list of the products returned by the query along with some basic listing info for each one.</p>
<p>Below is a portion of the NavigationContentList:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;NavigationContentList&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;NavigationItemList&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;SubCategoryId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Free Shipping&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreDepaId&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">94</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;NValue&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;100007611 600006050 600052012 4808&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;BrandId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreType&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">4</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ItemCount&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">194</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ElementValue&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;4808&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;SubCategoryId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Top Sellers&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreDepaId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;NValue&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;100007611 600006050 600052012 4802&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;BrandId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreType&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ItemCount&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">39</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ElementValue&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;4802&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...</div></td></tr></tbody></table></div>
<p>This section will also contain a group name:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;TitleItem&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;SubCategoryId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Description&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Useful Links&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreDepaId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;NValue&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;4800&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;BrandId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;StoreType&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ItemCount&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;CategoryId&quot;</span><span style="color: #339933;">:</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ElementValue&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;4800&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...</div></td></tr></tbody></table></div>
<p>The PaginationInfo and ProductListItem elements will look like the following:</p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; ...<br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;PaginationInfo&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;TotalCount&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">233</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;PageNumber&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;PageSize&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">20</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;ProductListItems&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;SellerId&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ItemOwnerType&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Crucial Ballistix 4GB (2 x 2GB) 240-Pin DDR3 SDRAM DDR3 2133 (PC3 17000) Desktop Memory with Thermal Sensor Model BL2KIT25664FN2139&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ItemGroupID&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ReviewSummary&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Rating&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">5</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;TotalReviews&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;[1]&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;IsCellPhoneItem&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Discount&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;FinalPrice&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;$104.99&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ItemNumber&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;20-148-372&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;MappingFinalPrice&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;$104.99&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;FreeShippingFlag&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;OriginalPrice&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;$104.99&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;IsComboBundle&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;MailInRebateText&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ProductStockType&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Model&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;BL2KIT25664FN2139&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ShowOriginalPrice&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Image&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;FullPath&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://images17.newegg.com/is/image/newegg/20-148-372-TS?$S125W$&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;SmallImagePath&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ThumbnailImagePath&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Title&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;SellerName&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;ParentItem&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ...</div></td></tr></tbody></table></div>
<p>At this point you might be wondering what good will all this do me if I can't get specifications on an item? Well, you can and here's how: In each ProductListItems element you'll find an ItemNumber, this is essentially the primary key that each product is related to within this interface to newegg's product list. Using the following url you can obtain the full details page on any given item using it's ItemNumber:</p>
<p><a href="http://www.ows.newegg.com/Products.egg/{ItemNumber}/Specification">http://www.ows.newegg.com/Products.egg/{ItemNumber}/Specification</a></p>
<div class="codecolorer-container javascript default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;SpecificationGroupList&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;GroupName&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Model&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;SpecificationPairList&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Crucial&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Brand&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Ballistix&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Series&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;BL2KIT25664FN2139&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Model&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;240-Pin DDR3 SDRAM&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Type&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;GroupName&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Tech Spec&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;SpecificationPairList&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;4GB (2 x 2GB)&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Capacity&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;DDR3 2133 (PC3 17000)&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Speed&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;9&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Cas Latency&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;9-10-9-24&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Timing&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;1.65V&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Voltage&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;No&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;ECC&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Unbuffered&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Buffered/Registered&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Dual Channel Kit&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Multi-channel Kit&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;GroupName&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Manufacturer Warranty&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;SpecificationPairList&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Lifetime limited&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Parts&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Value&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Lifetime limited&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;Key&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Labor&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;NeweggItemNumber&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;N82E16820148372&quot;</span><span style="color: #339933;">,</span> <br />
&nbsp; &nbsp; <span style="color: #3366CC;">&quot;Title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Crucial Ballistix 4GB (2 x 2GB) 240-Pin DDR3 SDRAM DDR3 2133 (PC3 17000) Desktop Memory with Thermal Sensor Model BL2KIT25664FN2139&quot;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>From this point on you can grab all of the features and specifications of any particular item you're interested in. In the near future I'll be writing a new post for both my memory and SSD analysis scripts using this interface.</p>
<p>The full code for my query builder is as follows, though you should note this was a quick script and is in no way complete or fully functional. As soon as it was to a useable point I moved onto the main point of this whole ordeal. You should also note that this requires CherryPy<sup>[<a href="http://www.bemasher.net/archives/1002#footnote_4_1002" id="identifier_4_1002" class="footnote-link footnote-identifier-link" title="CherryPy: CherryPy is a pythonic, object-oriented HTTP framework.">5</a>]</sup> and lxml<sup>[<a href="http://www.bemasher.net/archives/1002#footnote_5_1002" id="identifier_5_1002" class="footnote-link footnote-identifier-link" title="lxml: A Pythonic binding for the C libraries libxml2 and libxslt.">6</a>]</sup>. The end result of this program is a query which you can use to retrieve a list of products matching the options you've selected. This is mainly to simplify product list selection and to minimalize the need to hardcode in certain values as newegg as a tendency to change things around on a regular basis.</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">import</span> cherrypy<span style="color: #66cc66;">,</span> json<span style="color: #66cc66;">,</span> <span style="color: #dc143c;">urllib</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">urllib2</span><br />
<span style="color: #ff7700;font-weight:bold;">from</span> lxml <span style="color: #ff7700;font-weight:bold;">import</span> etree<br />
<span style="color: #ff7700;font-weight:bold;">from</span> lxml.<span style="color: black;">builder</span> <span style="color: #ff7700;font-weight:bold;">import</span> E<br />
<br />
<span style="color: #ff7700;font-weight:bold;">class</span> QueryBuilder<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> index<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; request <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://www.ows.newegg.com/Stores.egg/Menus&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response <span style="color: #66cc66;">=</span> request.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; data <span style="color: #66cc66;">=</span> json.<span style="color: black;">loads</span><span style="color: black;">&#40;</span>response<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; body <span style="color: #66cc66;">=</span> E.<span style="color: black;">body</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; ul <span style="color: #66cc66;">=</span> E.<span style="color: black;">ul</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> store <span style="color: #ff7700;font-weight:bold;">in</span> data:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ul.<span style="color: black;">append</span><span style="color: black;">&#40;</span>E.<span style="color: black;">li</span><span style="color: black;">&#40;</span>E.<span style="color: black;">a</span><span style="color: black;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; store<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Title'</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; href<span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'/Store?StoreID={}'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>store<span style="color: black;">&#91;</span><span style="color: #483d8b;">'StoreID'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; page <span style="color: #66cc66;">=</span> E.<span style="color: black;">html</span><span style="color: black;">&#40;</span>E.<span style="color: black;">body</span><span style="color: black;">&#40;</span>ul<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> etree.<span style="color: black;">tostring</span><span style="color: black;">&#40;</span>page<span style="color: #66cc66;">,</span> pretty_print<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; index.<span style="color: black;">exposed</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">True</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> Store<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: #66cc66;">,</span> StoreID<span style="color: #66cc66;">=</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> StoreID <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #008000;">None</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://www.ows.newegg.com/Stores.egg/Categories/{}&quot;</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>StoreID<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response <span style="color: #66cc66;">=</span> request.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data <span style="color: #66cc66;">=</span> json.<span style="color: black;">loads</span><span style="color: black;">&#40;</span>response<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; body <span style="color: #66cc66;">=</span> E.<span style="color: black;">body</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ul <span style="color: #66cc66;">=</span> E.<span style="color: black;">ul</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> category <span style="color: #ff7700;font-weight:bold;">in</span> data:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> category<span style="color: black;">&#91;</span><span style="color: #483d8b;">'CategoryType'</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">1</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ul.<span style="color: black;">append</span><span style="color: black;">&#40;</span>E.<span style="color: black;">li</span><span style="color: black;">&#40;</span>E.<span style="color: black;">a</span><span style="color: black;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; category<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Description'</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; href<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'/Search?StoreID={}&amp;CategoryID={}&amp;NodeID={}'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>StoreID<span style="color: #66cc66;">,</span> category<span style="color: black;">&#91;</span><span style="color: #483d8b;">'CategoryID'</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> category<span style="color: black;">&#91;</span><span style="color: #483d8b;">'NodeId'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ul.<span style="color: black;">append</span><span style="color: black;">&#40;</span>E.<span style="color: black;">li</span><span style="color: black;">&#40;</span>E.<span style="color: black;">a</span><span style="color: black;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; category<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Description'</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; href<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'/Category?StoreID={}&amp;CategoryID={}&amp;NodeID={}'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>StoreID<span style="color: #66cc66;">,</span> category<span style="color: black;">&#91;</span><span style="color: #483d8b;">'CategoryID'</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> category<span style="color: black;">&#91;</span><span style="color: #483d8b;">'NodeId'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; page <span style="color: #66cc66;">=</span> E.<span style="color: black;">html</span><span style="color: black;">&#40;</span>E.<span style="color: black;">body</span><span style="color: black;">&#40;</span>ul<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> etree.<span style="color: black;">tostring</span><span style="color: black;">&#40;</span>page<span style="color: #66cc66;">,</span> pretty_print<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;Invalid parameters.&quot;</span><br />
&nbsp; &nbsp; Store.<span style="color: black;">exposed</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">True</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> Category<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: #66cc66;">,</span> StoreID<span style="color: #66cc66;">,</span> CategoryID<span style="color: #66cc66;">,</span> NodeID<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">None</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#91;</span>StoreID<span style="color: #66cc66;">,</span> CategoryID<span style="color: #66cc66;">,</span> NodeID<span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; request <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://www.ows.newegg.com/Stores.egg/Navigation/{}/{}/{}&quot;</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>StoreID<span style="color: #66cc66;">,</span> CategoryID<span style="color: #66cc66;">,</span> NodeID<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response <span style="color: #66cc66;">=</span> request.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data <span style="color: #66cc66;">=</span> json.<span style="color: black;">loads</span><span style="color: black;">&#40;</span>response<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; body <span style="color: #66cc66;">=</span> E.<span style="color: black;">body</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ul <span style="color: #66cc66;">=</span> E.<span style="color: black;">ul</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> subcategory <span style="color: #ff7700;font-weight:bold;">in</span> data:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ul.<span style="color: black;">append</span><span style="color: black;">&#40;</span>E.<span style="color: black;">li</span><span style="color: black;">&#40;</span>E.<span style="color: black;">a</span><span style="color: black;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; subcategory<span style="color: black;">&#91;</span><span style="color: #483d8b;">'Description'</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; href<span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'/Search?StoreID={}&amp;CategoryID={}&amp;SubCategoryID={}&amp;NodeID={}'</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>StoreID<span style="color: #66cc66;">,</span> CategoryID<span style="color: #66cc66;">,</span> subcategory<span style="color: black;">&#91;</span><span style="color: #483d8b;">'CategoryID'</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> subcategory<span style="color: black;">&#91;</span><span style="color: #483d8b;">'NodeId'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; page <span style="color: #66cc66;">=</span> E.<span style="color: black;">html</span><span style="color: black;">&#40;</span>E.<span style="color: black;">body</span><span style="color: black;">&#40;</span>ul<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> etree.<span style="color: black;">tostring</span><span style="color: black;">&#40;</span>page<span style="color: #66cc66;">,</span> pretty_print<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;Invalid parameters.&quot;</span><br />
&nbsp; &nbsp; Category.<span style="color: black;">exposed</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">True</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> Search<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: #66cc66;">,</span> StoreID<span style="color: #66cc66;">=</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> CategoryID<span style="color: #66cc66;">=</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> SubCategoryID<span style="color: #66cc66;">=</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> NodeID<span style="color: #66cc66;">=</span><span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; url <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">&quot;http://www.ows.newegg.com/Search.egg/Advanced&quot;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; data <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;IsUPCCodeSearch&quot;</span>:&nbsp; &nbsp; &nbsp; <span style="color: #008000;">False</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;IsSubCategorySearch&quot;</span>:&nbsp; <span style="color: #008000;">True</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;isGuideAdvanceSearch&quot;</span>: <span style="color: #008000;">False</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;StoreDepaId&quot;</span>:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StoreID<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;CategoryId&quot;</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CategoryID<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;SubCategoryId&quot;</span>:&nbsp; &nbsp; &nbsp; &nbsp; SubCategoryID<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;NodeId&quot;</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NodeID<span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;BrandId&quot;</span>:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;NValue&quot;</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;Keyword&quot;</span>:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;Sort&quot;</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;FEATURED&quot;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;PageNumber&quot;</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; params <span style="color: #66cc66;">=</span> json.<span style="color: black;">dumps</span><span style="color: black;">&#40;</span>data<span style="color: black;">&#41;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;null&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;-1&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; request <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">Request</span><span style="color: black;">&#40;</span>url<span style="color: #66cc66;">,</span> params<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; response <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>request<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; data <span style="color: #66cc66;">=</span> json.<span style="color: black;">loads</span><span style="color: black;">&#40;</span>response.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> data<span style="color: black;">&#91;</span><span style="color: #483d8b;">'NavigationContentList'</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">None</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> etree.<span style="color: black;">tostring</span><span style="color: black;">&#40;</span>E.<span style="color: black;">pre</span><span style="color: black;">&#40;</span>json.<span style="color: black;">dumps</span><span style="color: black;">&#40;</span>data<span style="color: #66cc66;">,</span> indent<span style="color: #66cc66;">=</span><span style="color: #ff4500;">4</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> pretty_print<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; body <span style="color: #66cc66;">=</span> E.<span style="color: black;">body</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; form <span style="color: #66cc66;">=</span> E.<span style="color: black;">form</span><span style="color: black;">&#40;</span>name<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'PowerSearch'</span><span style="color: #66cc66;">,</span> action<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'GenerateURL'</span><span style="color: #66cc66;">,</span> method<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'GET'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; table <span style="color: #66cc66;">=</span> E.<span style="color: black;">table</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; form.<span style="color: black;">append</span><span style="color: black;">&#40;</span>table<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> section <span style="color: #ff7700;font-weight:bold;">in</span> data<span style="color: black;">&#91;</span><span style="color: #483d8b;">'NavigationContentList'</span><span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index <span style="color: #66cc66;">=</span> <span style="color: #ff4500;">0</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tr <span style="color: #66cc66;">=</span> E.<span style="color: black;">tr</span><span style="color: black;">&#40;</span>E.<span style="color: black;">td</span><span style="color: black;">&#40;</span>section<span style="color: black;">&#91;</span><span style="color: #483d8b;">'TitleItem'</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'Description'</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> colspan<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'3'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; table.<span style="color: black;">append</span><span style="color: black;">&#40;</span>tr<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> option <span style="color: #ff7700;font-weight:bold;">in</span> section<span style="color: black;">&#91;</span><span style="color: #483d8b;">'NavigationItemList'</span><span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> index % <span style="color: #ff4500;">3</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">0</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tr <span style="color: #66cc66;">=</span> E.<span style="color: black;">tr</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; table.<span style="color: black;">append</span><span style="color: black;">&#40;</span>tr<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index +<span style="color: #66cc66;">=</span> <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; checkbox <span style="color: #66cc66;">=</span> E.<span style="color: black;">td</span><span style="color: black;">&#40;</span>E.<span style="color: #008000;">input</span><span style="color: black;">&#40;</span>option<span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;Description&quot;</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">type</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;checkbox&quot;</span><span style="color: #66cc66;">,</span> name<span style="color: #66cc66;">=</span>section<span style="color: black;">&#91;</span><span style="color: #483d8b;">'TitleItem'</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'Description'</span><span style="color: black;">&#93;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot; &quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> value<span style="color: #66cc66;">=</span>option<span style="color: black;">&#91;</span><span style="color: #483d8b;">'NValue'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tr.<span style="color: black;">append</span><span style="color: black;">&#40;</span>checkbox<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> param<span style="color: #66cc66;">,</span> value <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#91;</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'StoreID'</span><span style="color: #66cc66;">,</span> StoreID<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'CategoryID'</span><span style="color: #66cc66;">,</span> CategoryID<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'SubCategoryID'</span><span style="color: #66cc66;">,</span> SubCategoryID<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'NodeID'</span><span style="color: #66cc66;">,</span>NodeID<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; form.<span style="color: black;">append</span><span style="color: black;">&#40;</span>E.<span style="color: #008000;">input</span><span style="color: black;">&#40;</span><span style="color: #008000;">type</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">'hidden'</span><span style="color: #66cc66;">,</span> name<span style="color: #66cc66;">=</span>param<span style="color: #66cc66;">,</span> value<span style="color: #66cc66;">=</span>value<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">KeyError</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">pass</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; form.<span style="color: black;">append</span><span style="color: black;">&#40;</span>E.<span style="color: #008000;">input</span><span style="color: black;">&#40;</span><span style="color: #008000;">type</span><span style="color: #66cc66;">=</span><span style="color: #483d8b;">'submit'</span><span style="color: #66cc66;">,</span> value<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'Submit'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; page <span style="color: #66cc66;">=</span> E.<span style="color: black;">html</span><span style="color: black;">&#40;</span>E.<span style="color: black;">body</span><span style="color: black;">&#40;</span>form<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> etree.<span style="color: black;">tostring</span><span style="color: black;">&#40;</span>page<span style="color: #66cc66;">,</span> pretty_print<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; Search.<span style="color: black;">exposed</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">True</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">def</span> GenerateURL<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: #66cc66;">,</span> StoreID<span style="color: #66cc66;">=</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> CategoryID<span style="color: #66cc66;">=</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> SubCategoryID<span style="color: #66cc66;">=</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> NodeID<span style="color: #66cc66;">=</span><span style="color: #008000;">None</span><span style="color: #66cc66;">,</span> **kwargs<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; NValue <span style="color: #66cc66;">=</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> arg <span style="color: #ff7700;font-weight:bold;">in</span> kwargs:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">type</span><span style="color: black;">&#40;</span>kwargs<span style="color: black;">&#91;</span>arg<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #008000;">list</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> value <span style="color: #ff7700;font-weight:bold;">in</span> kwargs<span style="color: black;">&#91;</span>arg<span style="color: black;">&#93;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NValue.<span style="color: black;">add</span><span style="color: black;">&#40;</span>value<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NValue.<span style="color: black;">add</span><span style="color: black;">&#40;</span>kwargs<span style="color: black;">&#91;</span>arg<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; NValue <span style="color: #66cc66;">=</span> <span style="color: #008000;">list</span><span style="color: black;">&#40;</span>NValue<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; NValue.<span style="color: black;">sort</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> StoreID <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">None</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; StoreID <span style="color: #66cc66;">=</span> -<span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> CategoryID <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">None</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CategoryID <span style="color: #66cc66;">=</span> -<span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> SubCategoryID <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">None</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SubCategoryID <span style="color: #66cc66;">=</span> -<span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> NodeID <span style="color: #ff7700;font-weight:bold;">is</span> <span style="color: #008000;">None</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NodeID <span style="color: #66cc66;">=</span> -<span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; data <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;StoreDepaId&quot;</span>:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>StoreID<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;CategoryId&quot;</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>CategoryID<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;SubCategoryId&quot;</span>:&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>SubCategoryID<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;NodeId&quot;</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>NodeID<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;BrandId&quot;</span>:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -<span style="color: #ff4500;">1</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;NValue&quot;</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">' '</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>NValue<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #483d8b;">&quot;PageNumber&quot;</span>: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff4500;">1</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: black;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> etree.<span style="color: black;">tostring</span><span style="color: black;">&#40;</span>E.<span style="color: black;">pre</span><span style="color: black;">&#40;</span>json.<span style="color: black;">dumps</span><span style="color: black;">&#40;</span>data<span style="color: #66cc66;">,</span> indent<span style="color: #66cc66;">=</span><span style="color: #ff4500;">4</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> pretty_print<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; GenerateURL.<span style="color: black;">exposed</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">True</span><br />
&nbsp; &nbsp; <br />
cherrypy.<span style="color: black;">quickstart</span><span style="color: black;">&#40;</span>QueryBuilder<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<ol class="footnotes"><li id="footnote_0_1002" class="footnote">And iOS devices I assume as well.</li><li id="footnote_1_1002" class="footnote">Because lets face it, that would be stupid.</li><li id="footnote_2_1002" class="footnote">... or get to the search query from selecting a root category in the main category listing for a store</li><li id="footnote_3_1002" class="footnote">At least this is the method used by the mobile app.</li><li id="footnote_4_1002" class="footnote"><a href="http://www.cherrypy.org/">CherryPy</a>: CherryPy is a pythonic, object-oriented HTTP framework.</li><li id="footnote_5_1002" class="footnote"><a href="http://lxml.de/">lxml</a>: A Pythonic binding for the C libraries libxml2 and libxslt.</li></ol>]]></content:encoded>
			<wfw:commentRss>http://www.bemasher.net/archives/1002/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>GitHub Repositories Feed</title>
		<link>http://www.bemasher.net/archives/340?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=github-repositories-feed</link>
		<comments>http://www.bemasher.net/archives/340#comments</comments>
		<pubDate>Tue, 05 May 2009 03:09:02 +0000</pubDate>
		<dc:creator>bemasher</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rss]]></category>

		<guid isPermaLink="false">http://www.bemasher.net/?p=340</guid>
		<description><![CDATA[I noticed at the bottom of the page on GitHub that there was an API link. I took a look at it and found it to be pretty interesting, it's actually really simple to use. You can export in xml, json and yaml. I thought to myself: "Hey it'd be great if I could put [...]]]></description>
			<content:encoded><![CDATA[<p>I noticed at the bottom of the page on GitHub that there was an API link. I took a look at it and found it to be pretty interesting, it's actually really simple to use. You can export in xml, json and yaml. I thought to myself: "Hey it'd be great if I could put a repositories feed in the sidebar of my blog here!".</p>
<p>So I took a look at the JSON output since it's small and really easy to deserialize in php, so I wrote up a quick little php script on the server I'm hosting my blog at that will spit out an RSS feed of the repositories I've created on GitHub. The code is as follows:</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?=</span><span style="color: #0000ff;">&quot;&lt;?xml version=<span style="color: #000099; font-weight: bold;">\&quot;</span>1.0<span style="color: #000099; font-weight: bold;">\&quot;</span>?&gt;&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&lt;rss version=&quot;2.0&quot;&gt;<br />
&nbsp; &lt;channel&gt;<br />
&nbsp; &nbsp; &lt;title&gt;BeMasher's GitHub Repositories&lt;/title&gt;<br />
&nbsp; &nbsp; &lt;link&gt;http://github.com/bemasher&lt;/link&gt;<br />
&nbsp; &nbsp; &lt;description&gt;BeMasher's GitHub Repositories&lt;/description&gt;<br />
&nbsp; &nbsp; &lt;language&gt;en-us&lt;/language&gt;<br />
&nbsp; &nbsp; &lt;pubDate&gt;<span style="color: #000000; font-weight: bold;">&lt;?=</span><a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D, d M Y G:i:s e&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/pubDate&gt;<br />
&nbsp; &nbsp; &lt;lastBuildDate&gt;<span style="color: #000000; font-weight: bold;">&lt;?=</span><a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D, d M Y G:i:s e&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/lastBuildDate&gt;<br />
&nbsp; &nbsp; &lt;webMaster&gt;bemasher@bemasher.net&lt;/webMaster&gt;<br />
&nbsp; &nbsp; &lt;ttl&gt;5&lt;/ttl&gt;<br />
<br />
<span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://github.com/api/v2/json/repos/show/bemasher&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/json_decode"><span style="color: #990000;">json_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #000088;">$today</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/date"><span style="color: #990000;">date</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D, d M Y G:i:s e&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;repositories&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$repository</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">echo</span> <span style="color: #0000cc; font-style: italic;">&lt;&lt;&lt;ITEM<br />
&nbsp; &nbsp; &lt;item&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;title&gt;{$repository[&quot;name&quot;]}&lt;/title&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;link&gt;{$repository[&quot;url&quot;]}&lt;/link&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;description&gt;{$repository[&quot;description&quot;]}&lt;/description&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;pubDate&gt;$today&lt;/pubDate&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &lt;guid&gt;{$repository[&quot;url&quot;]}&lt;/guid&gt;<br />
&nbsp; &nbsp; &lt;/item&gt;<br />
<br />
ITEM</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">?&gt;</span><br />
&nbsp; &nbsp; &lt;/channel&gt;<br />
&lt;/rss&gt;</div></td></tr></tbody></table></div>
<p>And if you look to the right you can see the RSS Widget in action displaying the output of the script. Cool huh?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bemasher.net/archives/340/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python ETR and Google Code Hosting</title>
		<link>http://www.bemasher.net/archives/229?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=python-etr-and-google-code-hosting</link>
		<comments>http://www.bemasher.net/archives/229#comments</comments>
		<pubDate>Mon, 02 Mar 2009 10:01:57 +0000</pubDate>
		<dc:creator>bemasher</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[etr]]></category>
		<category><![CDATA[gData]]></category>
		<category><![CDATA[google code]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.bemasher.net/?p=229</guid>
		<description><![CDATA[Earlier tonight I was talking to Nick a friend of mine who I've been working with recently on a ETR script. He's one of the webmasters for the University of Arizona Baja Racing Club. I had already written my own ETR script for easy entry of time records from my google calendar to the ETR [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier tonight I was talking to Nick a friend of mine who I've been working with recently on a ETR script. He's one of the webmasters for the University of Arizona Baja Racing Club.</p>
<p>I had already written my own ETR script for easy entry of time records from my google calendar to the ETR form website at my job. So I figured that i could just as easily modify it to work for him.</p>
<p>The main structure for his particular needs will be a main google account which the script will  authenticate with. All of the users that he wants to keep time records for will simply create and share a calendar with that account. Then when the script is run it will simply authenticate with the gdata api and retrieve a list of events and their descriptions for each shared calendar on the account. All of this data is then written to a csv file of the same name of the calendar along with the work week it was done in.</p>
<p>The script is more or less in proof-of-concept stage and still needs a lot of polishing but in the middle of doing this I found myself wanting to have a way to organize changes and revisions. I've briefly used subversion before this and never really made a habit of using it even though I should have. I suddenly remembered that Google Code Hosting provides subversion access to open source projects. So I went ahead and made a project of the name <a href="http://code.google.com/p/pythonetr/">pythonetr</a>.</p>
<p>It took about 15 minutes for me to download and install TortoiseSVN, a windows shell integrated gui for SVN. I then imported the first revision of the project to the subversion repository of the project on google code. After that I sent Nick a link to the page so that if there were any feature requests, bugs anything he wanted me to know about for the project he could just submit them as issues there.</p>
<p>Shortly after that I made some modifications to the code since the gdata api was only returning events between specified dates only if their cooresponding UTC time was within the date range. This breaks things if you expect only events between the date ranges that are returned are within your timezone. So I made all the changes and committed the new revision.</p>
<p>It's really satisfying to have a personal record of all changes made to code and I really should do this more often. I'd upload all my other projects but I believe there's a lifetime limit of 10 projects total for google code hosting.</p>
<p>If you're interested in checking out a copy of the project, you can do so with the following command:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">svn checkout</span> http:<span style="color: #000000; font-weight: bold;">//</span>pythonetr.googlecode.com<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span> pythonetr-read-only</div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bemasher.net/archives/229/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Data API</title>
		<link>http://www.bemasher.net/archives/89?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-data-api</link>
		<comments>http://www.bemasher.net/archives/89#comments</comments>
		<pubDate>Tue, 17 Feb 2009 19:58:56 +0000</pubDate>
		<dc:creator>bemasher</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[gData]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Google Calendar]]></category>
		<category><![CDATA[Google Data]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.bemasher.net/?p=89</guid>
		<description><![CDATA[I've got a friend who has been doing a lot of web development for the UA Baja Racing Club and I've been offering ideas for developing certain things he wanted on the website like electronic time sheet submission. I suggested he just make a pdf form and have that post to a php script on [...]]]></description>
			<content:encoded><![CDATA[<p>I've got a friend who has been doing a lot of web development for the UA Baja Racing Club and I've been offering ideas for developing certain things he wanted on the website like electronic time sheet submission. I suggested he just make a pdf form and have that post to a php script on his site which would then add the vales submitted to a table in his mysql database for the site. The reason I suggested a pdf form is that it would automatically do form validation for him without having to write or find extra code to do that in javascript or in the php part himself.</p>
<p>That ended up being a little too complicated for what he was looking at and wasn't a very feasible solution since he had no real experience with sql. So I started thinking about a few other ways he could do this that would be easier for him to implement himself. Eventually I remembered I wrote a python script for this very thing a few weeks ago that I use to tally up the amount of time I worked in the last pay period for when i'm getting ready to submit my time sheets at work.</p>
<p>The python script uses the gdata api to access my calendars and tally up the total amount of time I worked each day and displays it in a user-friendly format for entering into the website I submit the ETR to.</p>
<p>My grand idea was to simply use their master google account for the club to create calendars for each person//team, share them with each person such that they have permission to modify//create events. Then modify the python script I wrote to spit out CSV files for each shared calendar for easy import into excel (where they manage all of the info for each team and their members).</p>
<p>If you're interested in the script I could post it, it's mostly been kludged together from the python gdata tutorials I found so it's by no means original and I've only been programming in python for a couple of weeks so forgive any glaring mistakes:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">try</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">xml</span>.<span style="color: black;">etree</span> <span style="color: #ff7700;font-weight:bold;">import</span> ElementTree <span style="color: #808080; font-style: italic;"># for Python 2.5 users</span><br />
<span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">ImportError</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">from</span> elementtree <span style="color: #ff7700;font-weight:bold;">import</span> ElementTree<br />
<span style="color: #ff7700;font-weight:bold;">import</span> gdata.<span style="color: #dc143c;">calendar</span>.<span style="color: black;">service</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> gdata.<span style="color: black;">service</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> atom.<span style="color: black;">service</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> gdata.<span style="color: #dc143c;">calendar</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> atom<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">getopt</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">string</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">base64</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">datetime</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">operator</span><br />
<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<br />
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">datetime</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">time</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> gCalLogin<span style="color: black;">&#40;</span><span style="color: #dc143c;">email</span><span style="color: #66cc66;">,</span> password<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; calendar_service <span style="color: #66cc66;">=</span> gdata.<span style="color: #dc143c;">calendar</span>.<span style="color: black;">service</span>.<span style="color: black;">CalendarService</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; calendar_service.<span style="color: #dc143c;">email</span> <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">email</span><br />
&nbsp; &nbsp; calendar_service.<span style="color: black;">password</span> <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">base64</span>.<span style="color: black;">b64decode</span><span style="color: black;">&#40;</span>password<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; calendar_service.<span style="color: black;">source</span> <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">'PythonETR'</span><br />
&nbsp; &nbsp; calendar_service.<span style="color: black;">ProgrammaticLogin</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> calendar_service<br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> FindCalendar<span style="color: black;">&#40;</span>calendar_service<span style="color: #66cc66;">,</span> title<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; feed <span style="color: #66cc66;">=</span> calendar_service.<span style="color: black;">GetOwnCalendarsFeed</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> i<span style="color: #66cc66;">,</span> a_calendar <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">enumerate</span><span style="color: black;">&#40;</span>feed.<span style="color: black;">entry</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span><span style="color: black;">&#40;</span>a_calendar.<span style="color: black;">title</span>.<span style="color: black;">text</span> <span style="color: #66cc66;">==</span> title<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> a_calendar.<span style="color: #008000;">id</span>.<span style="color: black;">text</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">False</span><br />
&nbsp; &nbsp; <br />
<span style="color: #ff7700;font-weight:bold;">def</span> DateRangeQuery<span style="color: black;">&#40;</span>calendar_service<span style="color: #66cc66;">,</span> calendar_id<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'default'</span><span style="color: #66cc66;">,</span> start_date<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'2009-01-01'</span><span style="color: #66cc66;">,</span> end_date<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'2009-01-30'</span><span style="color: #66cc66;">,</span> event_title<span style="color: #66cc66;">=</span><span style="color: #483d8b;">'Work for ARL'</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; result <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; parseISO8601 <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;(<span style="color: #000099; font-weight: bold;">\d</span>+)-(<span style="color: #000099; font-weight: bold;">\d</span>+)-(<span style="color: #000099; font-weight: bold;">\d</span>+)T(<span style="color: #000099; font-weight: bold;">\d</span>+):(<span style="color: #000099; font-weight: bold;">\d</span>+):(<span style="color: #000099; font-weight: bold;">\d</span>+).(<span style="color: #000099; font-weight: bold;">\d</span>+)([+-]<span style="color: #000099; font-weight: bold;">\d</span>+:<span style="color: #000099; font-weight: bold;">\d</span>+)&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; query <span style="color: #66cc66;">=</span> gdata.<span style="color: #dc143c;">calendar</span>.<span style="color: black;">service</span>.<span style="color: black;">CalendarEventQuery</span><span style="color: black;">&#40;</span>calendar_id<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'private'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'full'</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; query.<span style="color: black;">start_min</span> <span style="color: #66cc66;">=</span> start_date<br />
&nbsp; &nbsp; query.<span style="color: black;">start_max</span> <span style="color: #66cc66;">=</span> end_date<br />
&nbsp; &nbsp; feed <span style="color: #66cc66;">=</span> calendar_service.<span style="color: black;">CalendarQuery</span><span style="color: black;">&#40;</span>query<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> i<span style="color: #66cc66;">,</span> an_event <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">enumerate</span><span style="color: black;">&#40;</span>feed.<span style="color: black;">entry</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>an_event.<span style="color: black;">title</span>.<span style="color: black;">text</span> <span style="color: #66cc66;">==</span> event_title<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: black;">&#40;</span>an_event.<span style="color: black;">event_status</span>.<span style="color: black;">value</span> <span style="color: #66cc66;">!=</span> <span style="color: #483d8b;">&quot;CANCELED&quot;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> when <span style="color: #ff7700;font-weight:bold;">in</span> an_event.<span style="color: black;">when</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; current_when <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span>parseISO8601.<span style="color: black;">findall</span><span style="color: black;">&#40;</span>when.<span style="color: black;">start_time</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> parseISO8601.<span style="color: black;">findall</span><span style="color: black;">&#40;</span>when.<span style="color: black;">end_time</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span><span style="color: black;">&#40;</span>current_when <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> result<span style="color: black;">&#41;</span>: <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result.<span style="color: black;">append</span><span style="color: black;">&#40;</span>current_when<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> result<br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> FindWeekBounds<span style="color: black;">&#40;</span>today<span style="color: #66cc66;">,</span> weekday<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; weekstart <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">datetime</span>.<span style="color: black;">timedelta</span><span style="color: black;">&#40;</span>days<span style="color: #66cc66;">=</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>weekday<span style="color: black;">&#41;</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; weekend <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">datetime</span>.<span style="color: black;">timedelta</span><span style="color: black;">&#40;</span>days<span style="color: #66cc66;">=</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">5</span> - <span style="color: #008000;">int</span><span style="color: black;">&#40;</span>weekday<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span>today - weekstart<span style="color: #66cc66;">,</span> today + weekend<span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; <br />
calendar_service <span style="color: #66cc66;">=</span> gCalLogin<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;emailaddress@gmail.com&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;passwordb64encoded&quot;</span><span style="color: black;">&#41;</span><br />
work_calendar <span style="color: #66cc66;">=</span> FindCalendar<span style="color: black;">&#40;</span>calendar_service<span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;maincalendarnamehere&quot;</span><span style="color: black;">&#41;</span><br />
p <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">re</span>.<span style="color: #008000;">compile</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'[<span style="color: #000099; font-weight: bold;">\w</span><span style="color: #000099; font-weight: bold;">\d</span>]*?%40group.calendar.google.com'</span><span style="color: #66cc66;">,</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">IGNORECASE</span><span style="color: black;">&#41;</span><br />
work_calendar <span style="color: #66cc66;">=</span> <span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>p.<span style="color: black;">findall</span><span style="color: black;">&#40;</span>work_calendar<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'%40'</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'@'</span><span style="color: black;">&#41;</span><br />
today <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">datetime</span>.<span style="color: black;">date</span>.<span style="color: black;">today</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
work_week <span style="color: #66cc66;">=</span> <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span><br />
start<span style="color: #66cc66;">,</span> end <span style="color: #66cc66;">=</span> FindWeekBounds<span style="color: black;">&#40;</span>date.<span style="color: black;">today</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> date.<span style="color: black;">today</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">weekday</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
work_events <span style="color: #66cc66;">=</span> DateRangeQuery<span style="color: black;">&#40;</span>calendar_service<span style="color: #66cc66;">,</span> calendar_id<span style="color: #66cc66;">=</span>work_calendar<span style="color: #66cc66;">,</span> start_date<span style="color: #66cc66;">=</span><span style="color: black;">&#40;</span>start - <span style="color: #dc143c;">datetime</span>.<span style="color: black;">timedelta</span><span style="color: black;">&#40;</span>days<span style="color: #66cc66;">=</span><span style="color: #ff4500;">7</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">isoformat</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span> end_date<span style="color: #66cc66;">=</span>end.<span style="color: black;">isoformat</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> event <span style="color: #ff7700;font-weight:bold;">in</span> work_events:<br />
&nbsp; &nbsp; start <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> event<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">if</span> x<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;-&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;+&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; end <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>x<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> x <span style="color: #ff7700;font-weight:bold;">in</span> event<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">if</span> x<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;-&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">&quot;+&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; start_datetime <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">datetime</span>.<span style="color: #dc143c;">datetime</span><span style="color: black;">&#40;</span>start<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> start<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> start<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> start<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> start<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> start<span style="color: black;">&#91;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> start<span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; end_datetime <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">datetime</span>.<span style="color: #dc143c;">datetime</span><span style="color: black;">&#40;</span>end<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> end<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> end<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> end<span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> end<span style="color: black;">&#91;</span><span style="color: #ff4500;">4</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> end<span style="color: black;">&#91;</span><span style="color: #ff4500;">5</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> end<span style="color: black;">&#91;</span><span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; duration <span style="color: #66cc66;">=</span> end_datetime - start_datetime<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">try</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; work_week<span style="color: black;">&#91;</span>start_datetime.<span style="color: black;">strftime</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%x&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> +<span style="color: #66cc66;">=</span> duration<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">KeyError</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; work_week<span style="color: black;">&#91;</span>start_datetime.<span style="color: black;">strftime</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;%x&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">=</span> duration<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
days <span style="color: #66cc66;">=</span> work_week.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
days.<span style="color: black;">sort</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> day <span style="color: #ff7700;font-weight:bold;">in</span> days:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> day<span style="color: #66cc66;">,</span> work_week<span style="color: black;">&#91;</span>day<span style="color: black;">&#93;</span></div></td></tr></tbody></table></div>
<p>I did a little more work on the script since I posted the code on pastebin and I found a much simpler method for retrieving lists of calendars:</p>
<div class="codecolorer-container python default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #ff7700;font-weight:bold;">def</span> GetAllCalendars<span style="color: black;">&#40;</span>calendar_service<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; feed <span style="color: #66cc66;">=</span> calendar_service.<span style="color: black;">GetAllCalendarsFeed</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">map</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x: x<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: #008000;">enumerate</span><span style="color: black;">&#40;</span>feed.<span style="color: black;">entry</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">def</span> GetUserCalendars<span style="color: black;">&#40;</span>calendar_service<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; feed <span style="color: #66cc66;">=</span> calendar_service.<span style="color: black;">GetOwnCalendarsFeed</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">map</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x: x<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: #008000;">enumerate</span><span style="color: black;">&#40;</span>feed.<span style="color: black;">entry</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #ff7700;font-weight:bold;">def</span> GetSharedCalendars<span style="color: black;">&#40;</span>calendar_service<span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">filter</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> x: x.<span style="color: black;">title</span>.<span style="color: black;">text</span> <span style="color: #ff7700;font-weight:bold;">not</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">map</span><span style="color: black;">&#40;</span><span style="color: #ff7700;font-weight:bold;">lambda</span> y: y.<span style="color: black;">title</span>.<span style="color: black;">text</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GetUserCalendars<span style="color: black;">&#40;</span>calendar_service<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; GetAllCalendars<span style="color: black;">&#40;</span>calendar_service<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://www.bemasher.net/archives/89/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

