line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Part of get-flash-videos. See get_flash_videos for copyright. |
2
|
|
|
|
|
|
|
package FlashVideo::Site::Googlevideosearch; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
24388
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
5
|
1
|
|
|
1
|
|
6
|
no warnings 'uninitialized'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
6
|
1
|
|
|
1
|
|
506
|
use FlashVideo::Mechanize; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub search { |
9
|
|
|
|
|
|
|
my($self, $search, $type) = @_; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $browser = FlashVideo::Mechanize->new; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$browser->get('http://video.google.com/'); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$browser->submit_form( |
16
|
|
|
|
|
|
|
with_fields => { |
17
|
|
|
|
|
|
|
q => $search, |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
return unless $browser->success; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my @links = map { |
24
|
|
|
|
|
|
|
chomp(my $name = $_->text); |
25
|
|
|
|
|
|
|
{ name => $name, url => $_->url_abs->as_string } |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
grep { |
28
|
|
|
|
|
|
|
$_->attrs->{onclick} =~ /return resultClick/ |
29
|
|
|
|
|
|
|
|| $_->attrs->{onmousedown} =~ /video_result/ |
30
|
|
|
|
|
|
|
|| $_->attrs->{class} eq 'l' |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
$browser->find_all_links(text_regex => qr/.+/); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
return @links; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |