Journal(2005) | Blog(2006) | RandomLink | WhoAmI | LiveBookmark | HomePage

<<Previous: 从细节处提升Perl性能  >>Next: Text::Textile

WWW::Mechanize && Google Group

Category: Modules   Keywords: Google Group WWW::Mechanize

觉得 Google 的 new 新闻组挺不错的,就申请了一个。http://groups-beta.google.com/group/fayland
拿来做什么还不知道,呵呵。暂时就打算去发表自己的 journal.

如果每次都登陆然后发表就太麻烦了。于是就想着用 WWW::Mechanize 来解决,然后做个 Eplanet 的功能,一键就发表了。简单写了下,挺简单的。5分种就搞定了。(终于发现自己 Perl 水平上去了,不容易呀。)

简单的代码如下,具体的 Eplanet 功能还要考虑将 HTML 转换为文本形式,迟点再搞:

use strict;
use warnings;
use WWW::Mechanize;

my $mech = WWW::Mechanize->new( autocheck => 1 );

# first, we should login
$mech->get('https://www.google.com/accounts/Login?hl=en&cd=US&service=groups2&continue=http:%2F%2Fgroups-beta.google.com%2Fgroup%2Ffayland%2Fpost');

$mech->submit_form(
    fields   => {
        Email => 'xxx@gmail.com', # your email, google account
        Passwd => 'yyy', # your password, please not be 'yyy'
    }
);

$mech->get('http://groups-beta.google.com/group/fayland/post');

$mech->submit_form(
    fields   => {
        subject => 'Test from WWW::Mechanize',
        body => 'Yap, WWW::Mechanize it',
    },
    button => 'Action.Post'
);

<<Previous: 从细节处提升Perl性能  >>Next: Text::Textile

Options: +Del.icio.us

Related items Created on 2005-04-13 18:49:43
Copyright 2004-2005 All Rights Reserved. Powered by Eplanet && Catalyst 5.62.