Code Monkey home page Code Monkey logo

mojo-mechanize's Introduction

NAME

Mojo::Transaction::HTTP::Role::Mechanize - Mechanize Mojo a little

SYNOPSIS

use Mojo::UserAgent;
use Mojo::Transaction::HTTP::Role::Mechanize;

my $ua = Mojo::UserAgent->new;
my $tx = $ua->get('/')->with_roles('+Mechanize');

# call submit immediately
my $submit_tx = $tx->submit('#submit-id', username => 'fry');
$ua->start($submit_tx);

# first extract form values
my $values = $tx->extract_forms->first->val;
$submit_tx = $tx->submit('#submit-id', counter => $values->{counter} + 3);
$ua->start($submit_tx);

DESCRIPTION

Role::Tiny based role to compose a form submission "trait" into Mojo::Transaction::HTTP.

METHODS

Mojo::Transaction::HTTP::Role::Mechanize implements the following method.

extract_forms

$collection = $tx->extract_forms;

Returns a Mojo::Collection of Mojo::DOM elements with activated Mojo::DOM::Role::Form that contains all the forms of the page.

submit

# result using selector
$submit_tx = $tx->submit('#id', username => 'fry');

# result without selector using default submission
$submit_tx = $tx->submit(username => 'fry');

# passing hash, rather than list, of values
$submit_tx = $tx->submit({username => 'fry'});

# passing hash, rather than list, of values and a selector
$submit_tx = $tx->submit('#id', {username => 'fry'});

Build a new Mojo::Transaction::HTTP object with "tx" in Mojo::UserAgent::Transactor and the contents of the form with the $id and merged values. If no selector is given, the first non-disabled button or appropriate input element (of type button, submit, or image) will be used for the submission.

AUTHOR

kiwiroy - Roy Storey [email protected]

CONTRIBUTORS

tekki - Rolf Stöckli [email protected]

lindleyw - William Lindley [email protected]

LICENSE

This library is free software and may be distributed under the same terms as perl itself.

SEE ALSO

Mojo::DOM::Role::Form, Mojolicious.

mojo-mechanize's People

Contributors

kiwiroy avatar lindleyw avatar tekki avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.