<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: agent code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 01:57:10 GMT</pubDate>
    <description>DZone Snippets: agent code</description>
    <item>
      <title>Getting Started With WWW::Mechanize</title>
      <link>http://snippets.dzone.com/posts/show/5134</link>
      <description>This Ruby code uses WWW:mechanize to act like a web browser.  &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt; require 'rubygems'&lt;br /&gt; require 'mechanize'&lt;br /&gt;&lt;br /&gt; agent = WWW::Mechanize.new&lt;br /&gt; page = agent.get('http://google.com/')&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Refer to the documentation at http://mechanize.rubyforge.org/mechanize/. Then gem install mechanize, and try running the code in an irb session.&lt;br /&gt;&lt;br /&gt;output (extract):&lt;br /&gt;&lt;code&gt;&lt;br /&gt;=&gt; #&lt;WWW::Mechanize::Page&lt;br /&gt; {url #&lt;URI::HTTP:0xfdbbbb286 URL:http://www.google.com/&gt;}&lt;br /&gt; {meta}&lt;br /&gt; {title "Google"}&lt;br /&gt; {iframes}&lt;br /&gt; {frames}&lt;br /&gt; {links&lt;br /&gt;  #&lt;WWW::Mechanize::Page::Link&lt;br /&gt;   "Images"&lt;br /&gt;   "http://images.google.com/imghp?hl=en&amp;tab=wi"&gt;&lt;br /&gt;  #&lt;WWW::Mechanize::Page::Link&lt;br /&gt;   "Maps"&lt;br /&gt;   "http://maps.google.com/maps?hl=en&amp;tab=wl"&gt;&lt;br /&gt;  #&lt;WWW::Mechanize::Page::Link&lt;br /&gt;   "News"&lt;br /&gt;   "http://news.google.com/nwshp?hl=en&amp;tab=wn"&gt;&lt;br /&gt;  #&lt;WWW::Mechanize::Page::Link&lt;br /&gt;   "Shopping"&lt;br /&gt;   "http://www.google.com/prdhp?hl=en&amp;tab=wf"&gt;&lt;br /&gt;  #&lt;WWW::Mechanize::Page::Link&lt;br /&gt;   "Gmail"&lt;br /&gt;   "http://mail.google.com/mail/?hl=en&amp;tab=wm"&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 12 Feb 2008 17:53:54 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5134</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Nokia - User Agent</title>
      <link>http://snippets.dzone.com/posts/show/3102</link>
      <description>// User Agent&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;Modello 3230&lt;br /&gt;"Nokia3230/2.0 (5.0614.0) SymbianOS/7.0s Series60/2.1 Profile/MIDP-2.0&lt;br /&gt;Configuration/CLDC-1.0"&lt;br /&gt;&lt;br /&gt;Modello 6260&lt;br /&gt;"Nokia6260/2.0 (3.0448.0) SymbianOS/7.0s Series60/2.1 Profile/MIDP-2.0&lt;br /&gt;Configuration/CLDC-1.0"&lt;br /&gt;&lt;br /&gt;Modello 6600&lt;br /&gt;"Nokia6600/1.0 (5.27.0) SymbianOS/7.0s Series60/2.0 Profile/MIDP-2.0&lt;br /&gt;Configuration/CLDC-1.0"&lt;br /&gt;&lt;br /&gt;Modello 6620&lt;br /&gt;"Nokia6620/2.0 (4.22.1) SymbianOS/7.0s Series60/2.1 Profile/MIDP-2.0&lt;br /&gt;Configuration/CLDC-1.0"&lt;br /&gt;&lt;br /&gt;Modello 6630&lt;br /&gt;"Nokia6630/1.0 (5.03.08) SymbianOS/8.0 Series60/2.6 Profile/MIDP-2.0&lt;br /&gt;Configuration/CLDC-1.1"&lt;br /&gt;&lt;br /&gt;Modello 6670&lt;br /&gt;"Nokia6670/2.0 (6.0540.0) SymbianOS/7.0s Series60/2.1 Profile/MIDP-2.0&lt;br /&gt;Configuration/CLDC-1.0"&lt;br /&gt;&lt;br /&gt;Modello 6680&lt;br /&gt;"Nokia6680/1.0 (4.04.07) SymbianOS/8.0 Series60/2.6 Profile/MIDP-2.0&lt;br /&gt;Configuration/CLDC-1.1"&lt;br /&gt;&lt;br /&gt;Modello 6681&lt;br /&gt;"Nokia6681/2.0 (5.37.01) SymbianOS/8.0 Series60/2.6 Profile/MIDP-2.0&lt;br /&gt;Configuration/CLDC-1.1"&lt;br /&gt;&lt;br /&gt;Modello 9300&lt;br /&gt;"Mozilla/4.0 (compatible; MSIE 5.0; Series80/2.0 Nokia9300/05.22&lt;br /&gt;Profile/MIDP-2.0 Configuration/CLDC-1.1)"&lt;br /&gt;&lt;br /&gt;Modello 9500&lt;br /&gt;"Mozilla/4.0 (compatible; MSIE 5.0; Series80/2.0 Nokia9500/4.51&lt;br /&gt;Profile/MIDP-2.0 Configuration/CLDC-1.1)"&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 07 Dec 2006 05:10:21 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3102</guid>
      <author>whitetiger ()</author>
    </item>
    <item>
      <title>Python - Change user-agent</title>
      <link>http://snippets.dzone.com/posts/show/3015</link>
      <description>// Cambiare user-agent con urllib&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import urllib&lt;br /&gt;&lt;br /&gt;class AppURLopener(urllib.FancyURLopener):&lt;br /&gt;&lt;br /&gt;	version = 'Nokia6630/1.0 (2.3.129) SymbianOS/8.0 Series60/2.6 Profile/MIDP-2.0 Configuration/CLDC-1.1'&lt;br /&gt;&lt;br /&gt;urllib._urlopener = AppURLopener()&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;// Cambiare user-agent con urllib2&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;import urllib2&lt;br /&gt;&lt;br /&gt;headers = { 'user-agent':'Nokia6630/1.0 (2.3.129) SymbianOS/8.0 Series60/2.6 Profile/MIDP-2.0 Configuration/CLDC-1.1',&lt;br /&gt;		    'keep-alive':'300',&lt;br /&gt;		    'content-type':'application/x-www-form-urlencoded'&lt;br /&gt;		  }&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 18 Nov 2006 15:14:46 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3015</guid>
      <author>whitetiger ()</author>
    </item>
    <item>
      <title>check user agent with javascript</title>
      <link>http://snippets.dzone.com/posts/show/2612</link>
      <description>// check user agent&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;a href="javascript:alert(navigator.userAgent)"&gt;User Agent&lt;/a&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 17 Sep 2006 17:00:15 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2612</guid>
      <author>ovhaag (Oliver Haag)</author>
    </item>
  </channel>
</rss>
