ãããVPSã§ã¨ããããWeb::Queryã使ããããã«ãã¦ã¿ã
Perlã§jQuery風ã®ã»ã¬ã¯ã¿ã使ã£ã¦ã¹ã¯ã¬ã¤ãã³ã°ãåºæ¥ãã¢ã¸ã¥ã¼ã«ãWeb::Queryã使ãããã®ã§ã¾ãã¯ä½¿ããããã«ãã¦ã¿ãã
ã¤ã³ã¹ãã¼ã«ã
$ sudo yum -y install cpan (ä¸ç¥) Installed: perl-CPAN.x86_64 0:1.9402-131.el6_4 Dependency Installed: perl-Digest-SHA.x86_64 1:5.47-131.el6_4 perl-ExtUtils-MakeMaker.x86_64 0:6.55-131.el6_4 perl-ExtUtils-ParseXS.x86_64 1:2.2003.0-131.el6_4 perl-Test-Harness.x86_64 0:3.17-131.el6_4 perl-devel.x86_64 4:5.10.1-131.el6_4 Complete! $ sudo cpan cpan> install CPAN cpan> reload cpan $ sudo cpan Module::Build $ sudo cpan Web::Query
ãã¹ãã
èªåè»ã®ã¡ã¼ã«ã¼åä¸è¦§ãgoo-netããåå¾ãããã¼ï¼
$ cat > ~/sample.pl use strict; use warnings; use Web::Query; binmode(STDOUT, ":utf8"); wq('http://www.goo-net.com/catalog/') ->find('div.box_searchUsedCar ul.line li a') ->each(sub{ $_[1]->each(sub{ my(undef, $wq) = @_; my $name_j = $wq->text(); my $name = $wq->attr('href'); $name =~s|^/catalog/(\w+)/index.html$|$1|; print qq|$name ($name_j)\n|; }) }); exit;
å®è¡ãã¦ã¿ã
$ perl ~/sample.pl LEXUS (ã¬ã¯ãµã¹) TOYOTA (ãã¨ã¿) NISSAN (æ¥ç£) HONDA (ãã³ã) MAZDA (ããã) EUNOS (ã¦ã¼ãã¹) FORD_JAPAN (æ¥æ¬ãã©ã¼ã) MITSUBISHI (ä¸è±) SUBARU (ã¹ãã«) DAIHATSU (ãã¤ãã) SUZUKI (ã¹ãºã) ISUZU (ããã) MITSUOKA (ãããªã«) RENAULT (ã«ãã¼) PEUGEOT (ãã¸ã§ã¼) CITROEN (ã·ããã¨ã³) VENTURI (ã´ã§ã³ãã¥ãªã¼) MERCEDES_BENZ (ã¡ã«ã»ãã¹ã»ãã³ã) AMG (AMG) MAYBACH (ãã¤ããã) MCC_SMART (ã¹ãã¼ã) BMW (BMW) BMW_ALPINA (BMWã¢ã«ãã) AUDI (ã¢ã¦ãã£) VOLKSWAGEN (ãã©ã«ã¯ã¹ã¯ã¼ã²ã³) MINI (MINI) OPEL (ãªãã«) PORSCHE (ãã«ã·ã§) EUROPE_FORD (ã¨ã¼ããããã©ã¼ã) YES (ã¤ã¨ã¹ï¼) VOLVO (ãã«ã) SAAB (ãµã¼ã) ROLLSROYCE (ãã¼ã«ã¹ãã¤ã¹) BENTLEY (ãã³ãã¬ã¼) JAGUAR (ã¸ã£ã¬ã¼) DAIMLER (ãã¤ã ã©ã¼) LAND_ROVER (ã©ã³ããã¼ãã¼) MG (MG) ROVER (ãã¼ãã¼) LOTUS (ãã¼ã¿ã¹) ASTON_MARTIN (ã¢ã¹ãã³ãã¼ãã£ã³) MORGAN (ã¢ã¼ã¬ã³) TVR (TVR) FIAT (ãã£ã¢ãã) ABARTH (ã¢ãã«ã) FERRARI (ãã§ã©ã¼ãª) LANCIA (ã©ã³ãã¢) ALFA_ROMEO (ã¢ã«ãã¡ãã¡ãª) MASERATI (ãã»ã©ãã£) LAMBORGHINI (ã©ã³ãã«ã®ã¼ã) AUTOBIANCHI (ã¢ã¦ããã¢ã³ã)
åè
http://d.hatena.ne.jp/lesamoureuses/20110222/1298317227