Skip to content

Instantly share code, notes, and snippets.

@b10m
Created October 29, 2012 15:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b10m/3974165 to your computer and use it in GitHub Desktop.
Save b10m/3974165 to your computer and use it in GitHub Desktop.
Fetch a random animal name suited for wiki page tagging
$ perl -MMojo::UserAgent -le 'Mojo::UserAgent->new->detect_proxy
->get("http://en.wikipedia.org/wiki/Chart_of_English_animal_nouns")
->res->dom->find("table.wikitable tr td a")
->shuffle->slice(0..2)->each(sub { print $_->text } );'
@damog
Copy link

damog commented Oct 31, 2012

Can't call method "text" on an undefined value at -e line 4.

@b10m
Copy link
Author

b10m commented Oct 31, 2012

Use a proxy where needed.

@damog
Copy link

damog commented Nov 1, 2012

~ $ echo $http_proxy
http://proxy_from_work:3128
~ $ perl -MMojo::UserAgent -le 'print Mojo::UserAgent->new

->get("http://en.wikipedia.org/wiki/Chart_of_English_animal_nouns")
->res->dom->find("table.wikitable tr td a")
->shuffle->first->text;'
Can't call method "text" on an undefined value at -e line 1.
~ $

@b10m
Copy link
Author

b10m commented Nov 2, 2012

There, added ->detect_proxy for you ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment