What is the wget command to submit data to this fo

2019-06-06 13:25发布

问题:

I am trying to post the name, email address, and message to this page:

http://zenlyzen.com/test1/index.php?main_page=contact_us

using wget. This command:

wget --post-data     'contactname=test&email=a@a.com&enquiry=testmessage' http://www.zenlyzen.com/test1/index.php?main_page=contact_us\&action=send%20method="post"

saves this page:

http://www.zenlyzen.com/wgettest.html

I've poked around with cookies and session cookies, to no avail.

Thanks in advance,

Mark

回答1:

Using curl :

$ mech-dump --forms 'http://zenlyzen.com/test1/index.php?main_page=contact_us'
(...)

POST http://zenlyzen.com/test1/index.php?main_page=contact_us&action=send&zenid=075b74c66fbc5a701712880eb31f39f3 [contact_us]
  securityToken=b48dfdc80002c49fa5f6b07f7dc9be65 (hidden readonly)
  contactname=                   (text)
  email=                         (text)
  enquiry=                       (textarea)
  should_be_empty=               (text)
  <NONAME>=<UNDEF>               (image)

(...)

mech-dump command comes with libwww-mechanize-perl under Debian and derivateds.

Finally :

curl -A "Mozilla/5.0" -L -b cookies.txt -c cookies.txt -s -d "contactname=XXX&mail=XXXX&enquiry=XXXX&should_be_empty="

(replace XXX with your inputs). This should work !

You can use LiveHttpHeaders firefox module to see the headers to reproduce.

See man curl to understand all the switches.



标签: wget