<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>Mahadeva &#187; twitter</title>
	<atom:link href="http://www.patriciomolina.com/tag/twitter/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.patriciomolina.com</link>
	<description>Blog de Patricio Molina</description>
	<lastBuildDate>Mon, 06 Feb 2012 04:26:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-sa/2.5/ar/</creativeCommons:license>		<item>
		<title>Identificando posibles &#8220;drops&#8221; de usuarios de Twitter, con Python</title>
		<link>http://www.patriciomolina.com/2010/01/identificando-posibles-drops-de-usuarios-de-twitter-con-python/</link>
		<comments>http://www.patriciomolina.com/2010/01/identificando-posibles-drops-de-usuarios-de-twitter-con-python/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 19:59:01 +0000</pubDate>
		<dc:creator>Pato</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.patriciomolina.com/?p=294</guid>
		<description><![CDATA[Hace un par de días se supo que Twitter liberará aquellos nombres de usuario que no hayan registrado actividad durante 6 meses o más. Les dejo una herramienta para obtener los días de inactividad de un usuario a través de &#8230; <a href="http://www.patriciomolina.com/2010/01/identificando-posibles-drops-de-usuarios-de-twitter-con-python/">Sigue leyendo <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hace un par de días <a href="http://thenextweb.com/socialmedia/2010/01/19/twitter-username-goldrush/">se supo</a> que <a href="http://twitter.com/">Twitter</a> liberará aquellos nombres de usuario que no hayan registrado actividad durante 6 meses o más.</p>
<p>Les dejo una herramienta para obtener los días de inactividad de un usuario a través de su último <em>status</em> publicado. Esta <a href="http://es.wikipedia.org/wiki/Clase_(inform%C3%A1tica)">clase</a> puede ser utilizada, por ejemplo, para recorrer <a href="http://wordlist.sourceforge.net/">listados de palabras</a> en búsqueda de nombres valiosos.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> twitter
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">urllib2</span>
<span style="color: #ff7700;font-weight:bold;">from</span> <span style="color: #dc143c;">datetime</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">datetime</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> UnknownUser<span style="color: black;">&#40;</span><span style="color: #008000;">Exception</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> UnknownStatus<span style="color: black;">&#40;</span><span style="color: #008000;">Exception</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">pass</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> TwitterExpire<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #008000;">self</span>.__t = twitter.<span style="color: black;">Api</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> verify<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, username<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">try</span>:
            <span style="color: #dc143c;">user</span> = <span style="color: #008000;">self</span>.__t.<span style="color: black;">GetUser</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">user</span>=username<span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #dc143c;">urllib2</span>.<span style="color: black;">HTTPError</span>:
            <span style="color: #ff7700;font-weight:bold;">raise</span> UnknownUser
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            status = <span style="color: #dc143c;">user</span>.<span style="color: black;">GetStatus</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> status:
                timestamp = status.<span style="color: black;">GetCreatedAtInSeconds</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
                d = <span style="color: #dc143c;">datetime</span>.<span style="color: black;">fromtimestamp</span><span style="color: black;">&#40;</span>timestamp<span style="color: black;">&#41;</span>
                td = <span style="color: #dc143c;">datetime</span>.<span style="color: black;">now</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> - d
                <span style="color: #ff7700;font-weight:bold;">return</span> td
            <span style="color: #ff7700;font-weight:bold;">else</span>:
                <span style="color: #ff7700;font-weight:bold;">raise</span> UnknownStatus
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span>username<span style="color: black;">&#41;</span>:
    te = TwitterExpire<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">try</span>:
        result = te.<span style="color: black;">verify</span><span style="color: black;">&#40;</span>username<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">except</span> UnknownUser:
        <span style="color: #ff7700;font-weight:bold;">print</span> u<span style="color: #483d8b;">&quot;User '%s' doesn't exist&quot;</span> <span style="color: #66cc66;">%</span> username
    <span style="color: #ff7700;font-weight:bold;">except</span> UnknownStatus:
        <span style="color: #ff7700;font-weight:bold;">print</span> u<span style="color: #483d8b;">&quot;Couldn't find any status for '%s'&quot;</span> <span style="color: #66cc66;">%</span> username
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> result
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&amp;</span>gt<span style="color: #66cc66;">;</span>= <span style="color: #ff4500;">2</span>:
        main<span style="color: black;">&#40;</span>username=<span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Algunos resultados:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mahadeva@blue:~$ python2.5 last_status.py patito
258 days, 11:16:49.425212
mahadeva@blue:~$ python2.5 last_status.py patricio
Couldn't find any status for 'patricio'
mahadeva@blue:~$ python2.5 last_status.py usuarioinexistente
User 'usuarioinexistente' doesn't exist
mahadeva@blue:~$ python2.5 last_status.py shitmydadsays
1 day, 22:35:44.434214</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.patriciomolina.com/2010/01/identificando-posibles-drops-de-usuarios-de-twitter-con-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mostrando búsquedas de Twitter en una página web con jQuery</title>
		<link>http://www.patriciomolina.com/2009/09/mostrando-busquedas-de-twitter-en-una-pagina-web-con-jquery/</link>
		<comments>http://www.patriciomolina.com/2009/09/mostrando-busquedas-de-twitter-en-una-pagina-web-con-jquery/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 05:53:43 +0000</pubDate>
		<dc:creator>Pato</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[twitter api]]></category>
		<category><![CDATA[twitter search]]></category>

		<guid isPermaLink="false">http://www.patriciomolina.com/?p=107</guid>
		<description><![CDATA[El programa consta de dos partes: el contenedor de resultados y el script. Contenedor de resultados Se trata del elemento HTML donde se mostrarán los resultados de una búsqueda. Los términos de búsqueda se establecen en el atributo title. Por &#8230; <a href="http://www.patriciomolina.com/2009/09/mostrando-busquedas-de-twitter-en-una-pagina-web-con-jquery/">Sigue leyendo <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>El programa consta de dos partes: el contenedor de resultados y el <em>script</em>.</p>
<p><strong>Contenedor de resultados</strong></p>
<p>Se trata del elemento HTML donde se mostrarán los resultados de una búsqueda. Los términos de búsqueda se establecen en el atributo <tt>title</tt>.</p>
<p>Por ejemplo, si quisiéramos mostrar los resultados del <em>tag</em> <a href="http://search.twitter.com/search?q=%23obama">#obama</a>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;twitter_search&quot; title=&quot;#obama&quot;&gt;&lt;/div&gt;</pre></td></tr></table></div>

<p>Podés crear todos los contenedores que quieras en la misma página, en el lugar que desees:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;twitter_search&quot; title=&quot;#python&quot;&gt;&lt;/div&gt;
&lt;div class=&quot;twitter_search&quot; title=&quot;#jquery&quot;&gt;&lt;/div&gt;</pre></td></tr></table></div>

<p><strong>El <em>script</em></strong></p>
<p>Son las instrucciones <a href="http://es.wikipedia.org/wiki/JavaScript">JavaScript</a> del programa que se encargará de todo el trabajo: obtendrá los términos de búsqueda, solicitará los resultados a través de la <a href="http://apiwiki.twitter.com/Twitter-Search-API-Method%3A-search">API de Twitter</a> y mostrará los resultados en el navegador.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Number of tweets to show for each column</span>
<span style="color: #003366; font-weight: bold;">var</span> MAX_RESULTS <span style="color: #339933;">=</span> <span style="color: #CC0000;">20</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">function</span> twitter_search<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://search.twitter.com/search.json?callback=?'</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">// Iterating over the different search columns</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.twitter_search'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> container <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">// Search terms are specified in the 'title' attribute</span>
		<span style="color: #003366; font-weight: bold;">var</span> search <span style="color: #339933;">=</span> container.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>search<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">// Showing column title</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>container.<span style="color: #660066;">siblings</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'h1'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				container.<span style="color: #660066;">parent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">prepend</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;h1&gt;'</span> <span style="color: #339933;">+</span> search <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/h1&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #003366; font-weight: bold;">var</span> since_id <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>container.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// Retrieve results since this id</span>
				since_id <span style="color: #339933;">=</span> container.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">':first'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #006600; font-style: italic;">// Request the results</span>
			$.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'q'</span><span style="color: #339933;">:</span> search<span style="color: #339933;">,</span> <span style="color: #3366CC;">'since_id'</span><span style="color: #339933;">:</span> since_id<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">// Processing those results, if any</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">results</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #000066; font-weight: bold;">in</span> data.<span style="color: #660066;">results</span>.<span style="color: #660066;">reverse</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						<span style="color: #003366; font-weight: bold;">var</span> r <span style="color: #339933;">=</span> data.<span style="color: #660066;">results</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">// Creating the result container</span>
						<span style="color: #003366; font-weight: bold;">var</span> div <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div id=&quot;#'</span> <span style="color: #339933;">+</span> r.<span style="color: #660066;">id</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">// Don't show this element now</span>
						div.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">// Adding some styles through .twitter_result</span>
						div.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'twitter_result'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">// Adding user's image</span>
						div.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;img src=&quot;'</span> <span style="color: #339933;">+</span> r.<span style="color: #660066;">profile_image_url</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; alt=&quot;'</span> <span style="color: #339933;">+</span> r.<span style="color: #660066;">from_user</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot; /&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">// Adding username</span>
						div.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;a href=&quot;http://twitter.com/'</span> <span style="color: #339933;">+</span> r.<span style="color: #660066;">from_user</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&quot;&gt;'</span> <span style="color: #339933;">+</span> r.<span style="color: #660066;">from_user</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">// Adding tweet</span>
						div.<span style="color: #660066;">append</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span&gt;'</span> <span style="color: #339933;">+</span> r.<span style="color: #660066;">text</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">'&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">// Adding corners</span>
						div.<span style="color: #660066;">corner</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">// Adding this result to the main container</span>
						container.<span style="color: #660066;">prepend</span><span style="color: #009900;">&#40;</span>div<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #006600; font-style: italic;">// Effect</span>
						div.<span style="color: #660066;">slideDown</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #006600; font-style: italic;">// Removing old tweets</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>container.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> MAX_RESULTS<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #006600; font-style: italic;">// Negative index</span>
					to_remove <span style="color: #339933;">=</span> MAX_RESULTS <span style="color: #339933;">-</span> container.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span>
					container.<span style="color: #660066;">children</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slice</span><span style="color: #009900;">&#40;</span>to_remove<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
						$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">slideUp</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">// Initial search </span>
	twitter_search<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">// Refresh the results every 5 seconds</span>
	setInterval<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;twitter_search();&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Acá pueden ver una demostración funcional del <em>script</em>: <strong><a href="http://www.patriciomolina.com/samples/twitter_search/">Twitter Search + jQuery</a></strong> (actualizado marzo de 2010).</p>
<p><strong>Aclaraciones de la demo</strong>:</p>
<ul>
<li>Casi no hay consumo de <em>bandwidth</em> de nuestro servidor, porque estoy usando <a href="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">jQuery 1.3.2 desde Google</a> y es el navegador del usuario quien se encarga de hacer el <em>request</em> de búsqueda a la API de Twitter</li>
<li>En la demo los resultados se actualizan automáticamente cada 5 segundos (<tt>setInterval("twitter_search();", 5000)</tt>)</li>
<li>Sigo una estructura <a href="http://es.wikipedia.org/wiki/FIFO">FIFO</a> (gracias al parámetro <tt>since_id</tt> de la API). Esto significa que iré agregando nuevos resultados en la cabecera mientras remuevo los más antiguos</li>
<li>La demo es <a href="http://validator.w3.org/check?uri=http%3A%2F%2Fwww.patriciomolina.com%2Fsamples%2Ftwitter_search%2F;accept=text%2Fhtml%2Capplication%2Fxhtml%2Bxml%2Capplication%2Fxml%3Bq%3D0.9%2C*%2F*%3Bq%3D0.8;accept-language=en-us%2Cen%3Bq%3D0.5;accept-charset=ISO-8859-1%2Cutf-8%3Bq%3D0.7%2C*%3Bq%3D0.7">XHTML 1.0 Transitional</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.patriciomolina.com/2009/09/mostrando-busquedas-de-twitter-en-una-pagina-web-con-jquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Consultando Crunchbase con Python</title>
		<link>http://www.patriciomolina.com/2009/09/consultando-crunchbase-con-python/</link>
		<comments>http://www.patriciomolina.com/2009/09/consultando-crunchbase-con-python/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 21:52:33 +0000</pubDate>
		<dc:creator>Pato</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[crunchbase]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[simplejson]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.patriciomolina.com/?p=91</guid>
		<description><![CDATA[Por mi trabajo, siempre estoy pendiente de lo que sucede en Crunchbase (de hecho, estoy suscripto a su feed de páginas recientes). Con tantas empresas y personas yendo y viniendo por Twitter, se transformó en una fuente de consulta permanente. &#8230; <a href="http://www.patriciomolina.com/2009/09/consultando-crunchbase-con-python/">Sigue leyendo <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Por mi trabajo, siempre estoy pendiente de lo que sucede en <a href="http://www.crunchbase.com/">Crunchbase</a> (de hecho, estoy suscripto a su <em><a href="http://es.wikipedia.org/wiki/Fuente_web">feed</a></em> de <a href="http://crunchbase.com/recently-added.rss">páginas recientes</a>). Con tantas empresas y personas yendo y viniendo por Twitter, se transformó en una fuente de consulta permanente.</p>
<p>¿Puedo consultar Crunchbase con Python? La respuesta es obvia <img src='http://www.patriciomolina.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Crunchbase tiene una <a href="http://es.wikipedia.org/wiki/Interfaz_de_programaci%C3%B3n_de_aplicaciones">API</a> muy interesante que devuelve resultados en formato <a href="http://es.wikipedia.org/wiki/JSON">JSON</a>. Pueden encontrar documentación sobre su uso en <a href="http://groups.google.com/group/crunchbase-api/">crunchbase-api</a>.</p>
<p>Para este programa estoy usando la librería <a href="http://pypi.python.org/pypi/simplejson/">simplejson</a> (<tt>sudo apt-get install python-simplejson</tt>)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>, <span style="color: #dc143c;">urllib</span>, simplejson
&nbsp;
api = <span style="color: #483d8b;">'http://api.crunchbase.com/v/1/search.js?%s'</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span>= <span style="color: #ff4500;">2</span>:
        q = <span style="color: #483d8b;">' '</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        source = <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlopen</span><span style="color: black;">&#40;</span>api <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlencode</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">'query'</span>: q<span style="color: black;">&#125;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        results = simplejson.<span style="color: black;">loads</span><span style="color: black;">&#40;</span>source.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> results<span style="color: black;">&#91;</span><span style="color: #483d8b;">'results'</span><span style="color: black;">&#93;</span>:
            <span style="color: #ff7700;font-weight:bold;">for</span> r <span style="color: #ff7700;font-weight:bold;">in</span> results<span style="color: black;">&#91;</span><span style="color: #483d8b;">'results'</span><span style="color: black;">&#93;</span>:
                name = r.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'name'</span><span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> name:
                    name = <span style="color: #483d8b;">' '</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>w.<span style="color: black;">capitalize</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> \
                        <span style="color: #ff7700;font-weight:bold;">for</span> w <span style="color: #ff7700;font-weight:bold;">in</span> r<span style="color: black;">&#91;</span><span style="color: #483d8b;">'permalink'</span><span style="color: black;">&#93;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'-'</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
                <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'%s (%s): %s'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>
                    name.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>,
                    r<span style="color: black;">&#91;</span><span style="color: #483d8b;">'namespace'</span><span style="color: black;">&#93;</span>.<span style="color: black;">capitalize</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>,
                    r<span style="color: black;">&#91;</span><span style="color: #483d8b;">'crunchbase_url'</span><span style="color: black;">&#93;</span>,
                <span style="color: black;">&#41;</span>       
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'No results for &quot;%s&quot;'</span> <span style="color: #66cc66;">%</span> q
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Usage: python %s &lt;keyword(s)&gt;'</span> <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Aquí tienen algunos resultados:</p>
<pre>mahadeva@blue:~$ python crunchbase.py
Usage: python crunchbase.py
mahadeva@blue:~$ python crunchbase.py popego
Popego (Company): http://www.crunchbase.com/company/popego
Santiago Siri (Person): http://www.crunchbase.com/person/santiago-siri
</pre>
<p>El programa en sí no es muy cómodo de usar (para eso existen los <em>add-ons</em> de de Firefox <img src='http://www.patriciomolina.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ), pero es un buen punto de partida para utilizar, por ejemplo, como una <a href="http://www.djangoproject.com/">aplicación de Django</a>, o un <em>bot</em> que interactúe con <a href="http://www.twitter.com/">Twitter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.patriciomolina.com/2009/09/consultando-crunchbase-con-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Buscador para Twitter, con Python, en 12 líneas</title>
		<link>http://www.patriciomolina.com/2009/09/buscador-para-twitter-con-python-en-12-lineas/</link>
		<comments>http://www.patriciomolina.com/2009/09/buscador-para-twitter-con-python-en-12-lineas/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 02:16:13 +0000</pubDate>
		<dc:creator>Pato</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[#pyconar2009]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[twitter search]]></category>

		<guid isPermaLink="false">http://www.patriciomolina.com/?p=58</guid>
		<description><![CDATA[Hoy estuve viendo los resultados de la búsqueda #pyconar2009 en Twitter Search, y me dije: &#8220;por qué no hacer las búsquedas desde consola, con Python?&#8221; Unos minutos después, aquí está el resultado: 1 2 3 4 5 6 7 8 &#8230; <a href="http://www.patriciomolina.com/2009/09/buscador-para-twitter-con-python-en-12-lineas/">Sigue leyendo <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hoy estuve viendo los resultados de la búsqueda <a href="http://search.twitter.com/search?q=%23pyconar2009">#pyconar2009</a> en <a href="http://search.twitter.com/">Twitter Search</a>, y me dije: &#8220;por qué no hacer las búsquedas desde consola, con Python?&#8221;</p>
<p>Unos minutos después, aquí está el resultado:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> feedparser, <span style="color: #dc143c;">urllib</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    feed_source = <span style="color: #483d8b;">'http://search.twitter.com/search.atom?%s'</span>
    q = <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Search term: '</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> q:
        f = feedparser.<span style="color: black;">parse</span><span style="color: black;">&#40;</span>feed_source <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">urllib</span>.<span style="color: black;">urlencode</span><span style="color: black;">&#40;</span><span style="color: black;">&#123;</span><span style="color: #483d8b;">'q'</span>: q<span style="color: black;">&#125;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> entry <span style="color: #ff7700;font-weight:bold;">in</span> f.<span style="color: black;">entries</span>:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'%s: &quot;%s&quot;'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>entry.<span style="color: black;">author</span>, entry.<span style="color: black;">title</span><span style="color: black;">&#41;</span> 
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>En este caso usé <a href="http://www.feedparser.org/">Universal Feed Parser</a> (<tt>$ sudo apt-get install python-feedparser</tt>), pero pueden utilizar la librería que más les guste <img src='http://www.patriciomolina.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.patriciomolina.com/2009/09/buscador-para-twitter-con-python-en-12-lineas/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

