Page
Library
Module
Module type
Parameter
Class
Class type
Source
Mechaml is a functional web scraping library that allows to :
Mechaml is built on top of existing libraries that provide low-level features : Cohttp and Lwt for asynchronous I/O and HTTP handling, and Lambdasoup to parse HTML. It provides an interface that handles the interactions between these and add a few other features.
The library is divided into 3 main modules :
The Format module provides helpers to manage the formatted content in forms such as date, colors, etc. For more details, see the documentation
opam install mechamlMechaml uses the dune build system, which can be installed through opam. Then, just run
dune buildto build the library.
Use dune build @doc to generate the documentation, dune runtest to build and execute tests, and dune build examples/XXX.exe to compile example XXX.
Here is sample of code that fetches a web page, fills a login form and submits it in the monadic style:
open Mechaml
module M = Agent.Monad
open M.Infix
let require msg = function
| Some a -> a
| None -> failwith msg
let action_login =
Agent.get "http://www.somewebsite.com"
>|= Agent.HttpResponse.page
>|= (function page ->
page
|> Page.form_with "[name=login]"
|> require "Can't find the login form !"
|> Page.Form.set "username" "mynick"
|> Page.Form.set "password" "@xlz43")
>>= Agent.submit
let _ =
M.run (Agent.init ()) action_loginMore examples are available in the dedicated folder.
GNU LGPL v3