How to submit html form with Haskell

痴心易碎 提交于 2020-01-02 09:57:12

问题


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 ?


回答1:


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




回答2:


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"


来源:https://stackoverflow.com/questions/22985481/how-to-submit-html-form-with-haskell

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!