{"id":33,"date":"2003-03-23T15:19:01","date_gmt":"2003-03-23T13:19:01","guid":{"rendered":"http:\/\/frenchfragfactory.net\/ozh\/archives\/2003\/03\/23\/perl-google-client\/"},"modified":"2007-05-08T13:59:31","modified_gmt":"2007-05-08T11:59:31","slug":"perl-google-client","status":"publish","type":"post","link":"https:\/\/planetozh.com\/blog\/2003\/03\/perl-google-client\/","title":{"rendered":"Perl google client"},"content":{"rendered":"<p>This script queries Google and returns the first result (the one you&#39;d get hitting the &quot;I Feel Lucky&quot; button). I did it because I wanted not to use LWP::Simple on a computer where the lib was missing. Consider this as is my minimalistic web client example.<br \/>\n(the fancy stuff that might confuse you, as &quot;print NOTICE&quot;, are for a PsyBNC integration. Ignore them)<\/p>\n<div class=\"igsh-code-box\" id=\"ig-sh-1\"><pre class=\"language-perl line-numbers\" data-no-optimize=\"1\" data-cfasync=\"false\"><code class=\"language-perl\">#!\/usr\/bin\/perl\r\n\r\nuse IO::Socket;\r\n$nick = shift (@ARGV);\r\n\r\nif ($#ARGV &lt; 0 ) {\r\nprint &quot;:g00gle NOTICE $nick :Err&quot;\u00a6. google what ffs m8 ?\\n&quot; ;\r\nexit;\r\n}\r\n\r\n$host = &quot;www.google.com&quot;;\r\n$document = &quot;\/search?btnI=\\&amp;q=&quot; . join (&quot;+&quot;, @ARGV);\r\n$kikoo=0;\r\n\r\n$EOL = &quot;\\015\\012&quot;;\r\n$BLANK = $EOL x 2;\r\n\r\n$remote = IO::Socket::INET-&gt;new(\r\nProto =&gt; &quot;tcp&quot;,\r\nPeerAddr =&gt; $host,\r\nPeerPort =&gt; &quot;http(80)&quot;,\r\n);\r\n\r\nunless ($remote) { die &quot;cannot connect to http daemon on $host&quot;; }\r\n$remote-&gt;autoflush(1);\r\nprint $remote &quot;GET $document HTTP\/1.0&quot; . $BLANK;\r\nwhile ( &lt;$remote&gt; ) {\r\nif (m\/^location\/i ) {\r\n$tutu = $_ ;\r\n$tutu=~s\/^location: \/\/i;\r\nprint &quot;:g00gle NOTICE $nick :$tutu&quot;; $kikoo = 1;\r\n} ;\r\n}\r\nclose $remote;\r\n\r\nprint &quot;:g00gle NOTICE $nick :No result ffs m8 !\\n&quot; unless $kikoo;<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Simple web client for google querying<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[2,42,41,9],"class_list":["post-33","post","type-post","status-publish","format-standard","hentry","tag-code","tag-google","tag-irc","tag-perl"],"_links":{"self":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/33","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/comments?post=33"}],"version-history":[{"count":0,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/posts\/33\/revisions"}],"wp:attachment":[{"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/media?parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/categories?post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/planetozh.com\/blog\/wp-json\/wp\/v2\/tags?post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}