{"id":11,"date":"2015-01-22T18:01:45","date_gmt":"2015-01-22T18:01:45","guid":{"rendered":"http:\/\/habett.fr\/wordpress\/?p=11"},"modified":"2015-01-22T18:01:45","modified_gmt":"2015-01-22T18:01:45","slug":"c-cgi","status":"publish","type":"post","link":"https:\/\/habett.fr\/blog\/2015\/01\/c-cgi\/","title":{"rendered":"c.cgi"},"content":{"rendered":"<p>Vu qu&rsquo;il y a de la demande pour \u00e7a, voici la source.<\/p>\n<div>\n<div>#!\/usr\/bin\/perl<\/div>\n<div><\/div>\n<div>use CGI;<\/div>\n<div>use WWW::Mechanize;<\/div>\n<div>use Encode;<\/div>\n<div><\/div>\n<div>$q = new CGI;<\/div>\n<div>$c = $q-&gt;param(&lsquo;code&rsquo;);<\/div>\n<div>$a = $q-&gt;param(&lsquo;article&rsquo;);<\/div>\n<div><\/div>\n<div>print \u00ab\u00a0Content-type: text\/html\\n\\n\u00a0\u00bb;<\/div>\n<div>$www = new WWW::Mechanize(agent =&gt; $ENV{&lsquo;HTTP_USER_AGENT&rsquo;});<\/div>\n<div>$www-&gt;get(&lsquo;http:\/\/www.legifrance.gouv.fr\/initRechCodeArticle.do&rsquo;);<\/div>\n<div>$www-&gt;form_number(2);<\/div>\n<div>($opt) = grep { $_ =~ \/$c\/i } $www-&gt;content =~ \/(&lt;option value=.*?&lt;\\\/option&gt;)\/g;<\/div>\n<div>unless ($opt) {<\/div>\n<div>\u00a0 $c = decode(&lsquo;utf-8&rsquo;,$c);<\/div>\n<div>\u00a0 ($opt) = grep { $_ =~ \/$c\/i } $www-&gt;content =~ \/(&lt;option value=.*?&lt;\\\/option&gt;)\/g;<\/div>\n<div>}<\/div>\n<div>$opt =~ \/value=\u00a0\u00bb(.*?)\u00a0\u00bb\/;<\/div>\n<div>$www-&gt;field(&lsquo;champCode&rsquo;,$1);<\/div>\n<div>$www-&gt;field(&lsquo;champNumArticle&rsquo;,$a);<\/div>\n<div>$www-&gt;submit();<\/div>\n<div>$url = $www-&gt;uri();<\/div>\n<div><\/div>\n<div>if ($www-&gt;title() =~ \/Article\/) {<\/div>\n<div>\u00a0 $url =~ s\/^\\.\\\/\\.\/http:\\\/\\\/legifrance.gouv.fr\/;<\/div>\n<div>\u00a0 print \u00ab\u00a0Content-type: text\/html\\n\\n&lt;meta http-equiv=\\\u00a0\u00bbRefresh\\\u00a0\u00bb content=\\\u00a0\u00bb0;url=$url\\\u00a0\u00bb \/&gt;\u00a0\u00bb;<\/div>\n<div>} else {<\/div>\n<div>\u00a0 print \u00ab\u00a0Content-type: text\/plain\\n\\nNo Result\u00a0\u00bb;<\/div>\n<div>}<\/div>\n<\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Vu qu&rsquo;il y a de la demande pour \u00e7a, voici la source. #!\/usr\/bin\/perl use CGI; use WWW::Mechanize; use Encode; $q = new CGI; $c = $q-&gt;param(&lsquo;code&rsquo;); $a = $q-&gt;param(&lsquo;article&rsquo;); print \u00ab\u00a0Content-type: text\/html\\n\\n\u00a0\u00bb; $www = new WWW::Mechanize(agent =&gt; $ENV{&lsquo;HTTP_USER_AGENT&rsquo;}); $www-&gt;get(&lsquo;http:\/\/www.legifrance.gouv.fr\/initRechCodeArticle.do&rsquo;); $www-&gt;form_number(2); ($opt) = grep { $_ =~ \/$c\/i } $www-&gt;content =~ \/(&lt;option value=.*?&lt;\\\/option&gt;)\/g; unless ($opt) { &hellip; <a href=\"https:\/\/habett.fr\/blog\/2015\/01\/c-cgi\/\" class=\"more-link\">Continuer la lecture de <span class=\"screen-reader-text\">c.cgi<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-11","post","type-post","status-publish","format-standard","hentry","category-archives"],"_links":{"self":[{"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/comments?post=11"}],"version-history":[{"count":1,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/posts\/11\/revisions"}],"predecessor-version":[{"id":12,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/posts\/11\/revisions\/12"}],"wp:attachment":[{"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/media?parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/categories?post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/habett.fr\/blog\/wp-json\/wp\/v2\/tags?post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}