blog/content/post/2008-09-01-00001017.md

2.8 KiB

title author date url wordtwit_post_info categories
getを使ったHTTPリクエストをperlでやるよ kazu634 2008-09-01 /2008/09/01/_1093/
O:8:"stdClass":13:{s:6:"manual";b:0;s:11:"tweet_times";i:1;s:5:"delay";i:0;s:7:"enabled";i:1;s:10:"separation";s:2:"60";s:7:"version";s:3:"3.7";s:14:"tweet_template";b:0;s:6:"status";i:2;s:6:"result";a:0:{}s:13:"tweet_counter";i:2;s:13:"tweet_log_ids";a:1:{i:0;i:4253;}s:9:"hash_tags";a:0:{}s:8:"accounts";a:1:{i:0;s:7:"kazu634";}}
LWP
Perl

Amazonでperlを検索するよ:

# === Libraries ===
use strict;
use warnings;
# LWP module
use LWP 5.64;
# Character Encoding
use Encode;
use utf8;
binmode( STDERR, ':raw :encoding(utf8)' );
# === main method ===
# get then content of the url.
my $browser  = LWP::UserAgent->new;
# getする先のURIを指定するよ
my $url = URI->new('http://www.amazon.co.jp/s/ref=nb_ss_gw?');
# Queryの指定
$url->query_form(
'__mk_ja_JP' => encode('shiftjis', 'カタカナ'),
'url' => encode('shiftjis', 'search-alias=aps'),
'field-keywords' => 'perl',
'x' => '0',
'y' => 
);
# 実際にリクエストを送る
my $response = $browser->get($url);
# デコードして表示
print decode('shiftjis', $response->content);
# print($url)