想关注几个优秀(泛指技术过硬,思维活跃,爱好广泛)的程序员。尤其是写Python的。
<code class="language-js"><span class="nx">javascript</span><span class="o">:</span><span class="kd">var</span> <span class="nx">hashes</span> <span class="o">=</span> <span class="p">[];</span> <span class="kd">var</span> <span class="nx">list</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s2">".member_mention"</span><span class="p">).</span><span class="nx">get</span><span class="p">().</span><span class="nx">filter</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span> <span class="kd">var</span> <span class="nx">h</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="nx">e</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">'data-hash'</span><span class="p">);</span> <span class="k">if</span> <span class="p">(</span><span class="nx">hashes</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">h</span><span class="p">)</span> <span class="o"> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="nx">hashes</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">h</span><span class="p">);</span> <span class="k">return</span> <span class="kc">true</span> <span class="p">}</span> <span class="k">else</span> <span class="p">{</span> <span class="k">return</span> <span class="kc">false</span> <span class="p">}</span> <span class="p">}).</span><span class="nx">sort</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">a</span><span class="p">,</span> <span class="nx">b</span><span class="p">)</span> <span class="p">{</span> <span class="kd">var</span> <span class="nx">atext</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="nx">a</span><span class="p">).</span><span class="nx">text</span><span class="p">(),</span> <span class="nx">btext</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="nx">b</span><span class="p">).</span><span class="nx">text</span><span class="p">();</span> <span class="k">if</span> <span class="p">(</span><span class="nx">atext</span> <span class="o">></span> <span class="nx">btext</span><span class="p">)</span> <span class="k">return</span> <span class="mi">1</span><span class="p">;</span> <span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">atext</span> <span class="o"> <span class="nx">btext</span><span class="p">)</span> <span class="k">return</span> <span class="o">-</span><span class="mi">1</span><span class="p">;</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span> <span class="p">});</span> <span class="kd">var</span> <span class="nx">target</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="s2">"#zh-question-detail"</span><span class="p">)[</span><span class="mi">0</span><span class="p">]).</span><span class="nx">empty</span><span class="p">();</span> <span class="nx">list</span><span class="p">.</span><span class="nx">forEach</span><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span> <span class="nx">target</span><span class="p">.</span><span class="nx">append</span><span class="p">(</span><span class="nx">e</span><span class="p">).</span><span class="nx">append</span><span class="p">(</span><span class="s2">"<br>"</span><span class="p">)</span> <span class="p">});</span> <span class="k">void</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> </span></span></code>
<code class="language-python"><span class="c">#coding=utf-8</span> <span class="kn">import</span> <span class="nn">re</span> <span class="kn">import</span> <span class="nn">urllib</span> <span class="k">def</span> <span class="nf">getCoder</span><span class="p">(</span><span class="n">url</span><span class="p">):</span> <span class="n">page</span> <span class="o">=</span> <span class="n">urllib</span><span class="o">.</span><span class="n">urlopen</span><span class="p">(</span><span class="n">url</span><span class="p">)</span> <span class="n">html</span> <span class="o">=</span> <span class="n">page</span><span class="o">.</span><span class="n">read</span><span class="p">()</span> <span class="n">rule</span> <span class="o">=</span> <span class="s">r'<a data-hash=".*?" href="(.*?)" class=".*?">@.*?</a>'</span> <span class="n">coderList</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">rule</span><span class="p">,</span><span class="n">html</span><span class="p">)</span> <span class="k">for</span> <span class="n">coderName</span> <span class="ow">in</span> <span class="n">coderList</span><span class="p">:</span> <span class="k">print</span> <span class="n">coderName</span> <span class="n">getCoder</span><span class="p">(</span><span class="s">"http://www.zhihu.com/question/22576739"</span><span class="p">)</span> </code>