McBear Holden
McBear Holden

Reputation: 5901

How to submit html form with Haskell

I know how to use http-conduit package's simplehttp to retrieve a page from an URL. Now what if on that web page there is an input text field and a submit button. Can I also use http-conduit to fill that text field and push the button and retrieve the resulting page ?

Upvotes: 2

Views: 421

Answers (2)

Sibi
Sibi

Reputation: 48654

According to Snoyman, it seems you can do it with http-conduit. But you may want to look on Sphider package which is developed specifically for that purpose. In fact, their hackage page has given an example for submitting html form:

runShpider $ do
      download "http://apage.com"
      theForm : _ <- getFormsByAction "http://anotherpage.com"
      sendForm $ fillOutForm theForm $ pairs $ do
            "occupation" =: "unemployed Haskell programmer"
            "location" =: "mother's house"

Upvotes: 2

Michael Snoyman
Michael Snoyman

Reputation: 31315

Yes, you can use either urlEncodedBody or, for multipart messages, the MultipartFormData module.

Upvotes: 2

Related Questions