我如何使用Perl的Google :: Search来查找特定的URL? [英] How do I use Perl's Google::Search to look for specific URLs?

查看:157
本文介绍了我如何使用Perl的Google :: Search来查找特定的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基于AJAX Search API的Google :: Search模块看起来效果不好,或者它只是我?

For例如,我使用Firefox来搜索谷歌: http://bloggingheads.tv/forum/ member.php?u = 12129



它带来的结果。



但是,当我使用模块:

  $ google_search = Google :: Search->网页(q =>http:// bloggingheads .tv / forum / member.php?u = 12129); 
@result = $ google_search->全部;

我没有在数组中找到任何东西。

任何想法?



看起来像这个API不会带来像手动搜索一样的结果,我错过了什么?

解决方案

我有一个与西里尔语查询类似的问题。来自CPAN的 Google :: Search REST :: Google 对我来说都不起作用 - 他们回馈较少或者与手动测试相比没有结果。

最后,我用 WWW :: Mechanize HTML :: TreeBuilder作为



以下是获取结果统计信息的示例:

  my $ tree = HTML :: TreeBuilder-> new_from_content($ content); 

if(my $ div = $ tree-> look_down(_tag =>'div',id =>'resultStats')){
my $ stats = $ div- > as_text();
}
其他{warnno stats}


The Google::Search module, which is based on the AJAX Search API, doesn't seems to work very well, or it is just me?

For example, I use firefox to search google for: http://bloggingheads.tv/forum/member.php?u=12129

It brings results.

But when I use the module this way:

$google_search = Google::Search->Web ( q => "http://bloggingheads.tv/forum/member.php?u=12129" );
@result =  $google_search->all;

I get nothing in the array.

Any idea?

Seems like this API doesn't bring the same results like when searching manually, am I missing something?

解决方案

I had a similar problem with cyrillic queries. Both Google::Search and REST::Google from CPAN didn't work for me - they were giving back fewer or no results compared to manual test.

Eventually I wrote a scraping module using WWW::Mechanize and HTML::TreeBuilder.

Here's a sample to get result stats:

my $tree = HTML::TreeBuilder->new_from_content($content);

if (my $div = $tree->look_down(_tag => 'div', id => 'resultStats')) {
    my $stats = $div->as_text();
}
else { warn "no stats" }

这篇关于我如何使用Perl的Google :: Search来查找特定的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆