Programmatic Form Submit

前端 未结 4 434
遥遥无期
遥遥无期 2021-01-14 16:26

I want to scrape the contents of a webpage. The contents are produced after a form on that site has been filled in and submitted.

I\'ve read on how to scrape the en

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-14 17:13

    you'll need to generate a HTTP request containing the data for the form.

    The form will look something like:

    ...

    This tells you the url to request is www.example.com/submit.php and your request should be a POST.

    In the form will be several input items, eg:

     ... 
    

    you need to create a string of all these input name=value pairs encoded for a URL appended to the end of your requested URL, which now becomes www.example.com/submit.php?itemnumber=5234&otherinput=othervalue etc... This will work fine for GET. POST is a little trickier.

    
    

    Just follow S.Lott's links for some much easier to use library support :P

提交回复
热议问题