13 April 2005
This post may be outdated due to it was written on 2005. The links may be broken. The code may be not working anymore. Leave comments if needed.
觉得 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 => '[email protected]', # 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'
);


blog comments powered by Disqus