Why can't I fetch wikipedia pages with LWP::Simple?

前端 未结 5 836
我在风中等你
我在风中等你 2021-01-11 16:52

I\'m trying to fetch Wikipedia pages using LWP::Simple, but they\'re not coming back. This code:

#!/usr/bin/perl
use strict;
use LWP::Simple;

print get(\"ht         


        
5条回答
  •  甜味超标
    2021-01-11 17:27

    You can also just set the UA on the LWP::Simple module - just import the $ua variable, and it'll allow you to modify the underlying UserAgent:

    use LWP::Simple qw/get $ua/;
    $ua->agent("WikiBot/0.1");
    print get("http://en.wikipedia.org/wiki/Stack_overflow");
    

提交回复
热议问题