Skip to content

Commit

Permalink
more reliable examples for Mojo::UserAgent
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jun 15, 2013
1 parent 78f1e0b commit ac9b0b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions lib/Mojo/UserAgent.pm
Expand Up @@ -498,11 +498,10 @@ Mojo::UserAgent - Non-blocking I/O HTTP and WebSocket user agent
->res->json('/results/0');
# Extract data from HTML and XML resources
say $ua->get('mojolicio.us')->res->dom->html->head->title->text;
say $ua->get('www.perl.org')->res->dom->html->head->title->text;
# Scrape the latest headlines from a news site
say $ua->max_redirects(5)->get('www.reddit.com/r/perl/')
->res->dom('p.title > a.title')->pluck('text')->shuffle;
# Scrape information from websites
say $ua->get('mojolicio.us')->res->dom('h1, h2')->pluck('text')->shuffle;
# IPv6 PUT request with content
my $tx
Expand All @@ -514,7 +513,7 @@ Mojo::UserAgent - Non-blocking I/O HTTP and WebSocket user agent
# TLS certificate authentication and JSON POST
my $tx = $ua->cert('tls.crt')->key('tls.key')
->post('https://mojolicio.us' => json => {top => 'secret'});
->post('https://example.com' => json => {top => 'secret'});
# Blocking parallel requests (does not work inside a running event loop)
my $delay = Mojo::IOLoop->delay;
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -1032,7 +1032,7 @@ The request can be customized as well.

You can follow redirects and view the headers for all messages.

$ mojo get -r -v http://reddit.com 'head > title'
$ mojo get -r -v http://google.com 'head > title'

Extract just the information you really need from JSON data structures.

Expand Down

0 comments on commit ac9b0b2

Please sign in to comment.