2013-10-30 Accessing Facebook by LWP
Usually, we can get the content of a url by the following code in Perl
1
perl -MLWP::Simple -e 'getprint "http://www.google.com"';
Copied!
But if you try to use it to access Facebook, like this
1
perl -MLWP::Simple -e 'getprint "http://www.facebook.com"';
Copied!
you will get a page "Upadte your browser" instead of the real one. That's because Facebook doesn't like the default UserAgent of LWP or WWW::Curl.
The simplest way to solve it is to change the default LWP user agent string to your own string.
1
perl -e 'use LWP::Simple qw($ua get); $ua->agent("My agent/1.0"); print get "http://www.facebook.com";'
Copied!
最近更新 1yr ago
复制链接