Coder Social home page Coder Social logo

mechanizerl's Introduction

mechanizerl

A clone of WWW::Mechanize for Erlang, with perhaps a bit of Test::WWW::Mechanize and Webtest for good measure. Named according to the seeming defacto convention of inserting "erl" in silly places in the name. This is primarily a convenience wrapper around httpc.

Examples:

erl -pa ebin -boot start_sasl -s inets -s xmerl -s mechanizerl

1> Mech = mechanizerl:new().
{mechanizerl,<0.64.0>}
2> Mech:get("http://google.com/").
ok
3> Mech:submit_form("search", [{q, "mechanizerl"}]).
ok
4> Mech:body().
<<"<html>...">>

Caveats:

  • The interface isn't as Erlangy as it could be (it uses the lowly tuple calls), as I tried to follow the WWW::Mechanize API closely to facilitate translating old tests I had written in perl into Erlang. Part of the efficacy of Mechanize's interface is its statefulness.
  • This uses xmerl to parse the HTML it receives. This works for me, since I tend to write HTML in an XHTML-ish fashion, but be warned that it will choke on lots of other HTML. I considered using one of the HTML parsers from YAWS or Mochiweb, but it seemed unnecessary for my purposes.
  • Strings are used throughout rather than binaries, for convenience rather than efficiency.
  • I've only implemented so far the subset of WWW::Mechanize's functionality that I actually use. For example, cookies are always enabled. Patches Thoughtfully Considered.
  • Lists are used in numerous places where more sophisticated data structures would be more efficient. Making the simplest thing that would work trumped efficiency in this first version.

To do:

  • Enforce constraints on fields (select options, maxlength, et cetera);
  • More extensive testing: replay-based testing of redirects, et cetera;
  • File upload;
  • Examples and documentation.

Contact

Julian Squires <[email protected]>

mechanizerl's People

Contributors

tokenrove avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar aliraza avatar James Cloos avatar  avatar  avatar

Forkers

ysei

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.