This file is indexed.

/usr/share/perl5/Scrappy/Scraper/UserAgent.pm is in libscrappy-perl 0.94112090-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package Scrappy::Scraper::UserAgent;

BEGIN {
    $Scrappy::Scraper::UserAgent::VERSION = '0.94112090';
}

# load OO System
use Moose;

# load other libraries
use Carp;
use FindBin;
use File::ShareDir ':ALL';
use File::Slurp;

has 'name'    => (is => 'rw', isa => 'Str');
has 'options' => (is => 'rw', isa => 'HashRef');

sub random_user_agent {
    my $self = shift;
    my ($browser, $os) = @_;

    $browser = 'any' unless $browser;

    $browser = 'explorer'
      if lc($browser) eq 'internet explorer'
          || lc($browser) eq 'explorer'
          || lc($browser) eq 'ie';

    $browser = lc $browser;

    my @browsers = ('explorer', 'chrome', 'firefox', 'opera', 'safari');

    my @oss = ('Windows', 'Linux', 'Macintosh');

    if ($browser ne 'any') {
        croak("Can't load user-agents from unrecognized browser $browser")
          unless grep /^$browser$/, @browsers;
    }

    if ($os) {
        $os = ucfirst(lc($os));
        croak("Can't filter user-agents with an unrecognized Os $os")
          unless grep /^$os$/, @oss;
    }

    my @selection = ();
    $self->options({})
      unless defined $self->options;

    if ($browser eq 'any') {
        if ($self->options->{any}) {
            @selection = @{$self->options->{any}};
        }
        else {
            foreach my $file (@browsers) {
                my $u = dist_dir('Scrappy') . "/support/$file.txt";
                $u = "share/support/$file.txt" unless -e $u;
                push @selection, read_file($u);
            }
            $self->options->{'any'} = [@selection];
        }
    }
    else {
        if ($self->options->{$browser}) {
            @selection = @{$self->options->{$browser}};
        }
        else {
            my $u = dist_dir('Scrappy') . "/support/$browser.txt";
            $u = "share/support/$browser.txt" unless -e $u;
            push @selection, read_file($u);
            $self->options->{$browser} = [@selection];
        }
    }

    @selection = grep /$os/, @selection if $os;

    $self->name($selection[rand(@selection)] || '');
    return $self->name;
}

1;