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

前端 未结 5 801
我在风中等你
我在风中等你 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:39

    Because Wikipedia is blocking the HTTP user-agent string used by LWP::Simple.

    You will get a "403 Forbidden"-response if you try using it.

    Try the LWP::UserAgent module to work around this, setting the agent-attribute.

提交回复
热议问题