Forum Moderators: coopster

Message Too Old, No Replies

about using wget in linux ....

         

Hevymetal

10:10 am on Sep 8, 2004 (gmt 0)

10+ Year Member



Hi

I want to get page source with wget and i want to give some variable value with POST method.

with this url, the POST variable name is "example_name" and i want to apply value "testing"to it.

So in php source it would look like:

$_POST["example_name"]="testing";

But i want to know the excact command line in linux to do that operation.

something like
wget --post-data=STRING www.url.com

but with the corect syntax.

thnx

vincevincevince

5:12 pm on Sep 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In short, so far as I know, you can't.

You can use cURL (check php.net for info), which is probably the easiest way to grab pages resulting from POST forms.

Or.. you can use lynx, through which you can send POST data.

nalin

6:09 pm on Sep 8, 2004 (gmt 0)

10+ Year Member



STRING here should be 'example_name=testing' (testing may need to be quote enclosed, I cant remeber on this one).

If posting two or more variables use && as a seperator (the post data is passed similarly to url encoded variable value pairs). The man file (man wget) has atleast one example of post string.

Hevymetal

6:14 pm on Sep 8, 2004 (gmt 0)

10+ Year Member



I don't have installed curl and don't want to.

With wget in linux it is quite easy to accomplish that.

With the excact info:

wget --post-data 'example_name=testing' www.url.com

But with that method i get problems in PHP functions exec and popen.
Error comes with --post-data ' ' -- i think it gets confused because of the coates.

Allso i don't want to save it to a file with wget.

I am really interested - how to do that(-post_data) with lynx.

nalin

7:12 pm on Sep 8, 2004 (gmt 0)

10+ Year Member



relevant man page example:
(shows use of posting login information in order to get (and save) a cookie and then reuse of the cookie)

# Log in to the server. This can be done only once.
wget --save-cookies cookies.txt \
--post-data 'user=foo&password=bar' \
h**p://example.com/auth.php
#Now grab the page or pages we care about.
wget --load-cookies cookies.txt \
-p h**p://example.com/interesting/article.php

You can also try echoing the post string to a file and using post-file parameter to eliminate the quotes

<edit>
Also the save headers flag (-s it think though might be -h) is useful for getting a more exacting error message. I would try double quotes around "testing" if unquoted does not work...

[edited by: ergophobe at 8:04 pm (utc) on Sep. 8, 2004]
[edit reason] exemplified and delinked URLs [/edit]