Shell: Connecting to a website and accessing a field

后端 未结 4 1367
面向向阳花
面向向阳花 2021-01-03 02:39

I want to write a script that takes an argument which is text, opens a connection to a specific website and input the arg into text field using the field\'s ID. Is this poss

4条回答
  •  耶瑟儿~
    2021-01-03 02:57

    ... "opens a connection to a specific website and input the arg into text field using the field's ID" ...

    You mean you want to fill & send a HTML

    ...
    , right?

    I would use curl (http://curl.haxx.se/). With curl you can automate HTTP POST requests very easily, suppose you have website with following form (excerpt from: http://curl.haxx.se/docs/httpscripting.html):

    this command would fill & send the form (let's pretend that form is available on http://www.example.com/when.cgi):

    curl --data "birthyear=1905&press=%20OK%20" http://www.example.com/when.cgi
    

提交回复
热议问题