Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Curl Help

Curl Help
Thread Tools
timmerk
Mac Elite
Join Date: Jan 2001
Status: Offline
Reply With Quote
Feb 8, 2004, 03:35 AM
 
Hi,

Is there an option to make curl not get the HTML? I just want it to get the cookie of a page.

Also, how can I submit a form with curl using PHP? I know what data needs to be sent.

Thanks!
     
Arkham_c
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Feb 8, 2004, 02:06 PM
 
Originally posted by timmerk:
Hi,

Is there an option to make curl not get the HTML? I just want it to get the cookie of a page.

Also, how can I submit a form with curl using PHP? I know what data needs to be sent.
To get the cookies:

Code:
-D/--dump-header <file> Write the protocol headers to the specified file. This option is handy to use when you want to store the cookies that a HTTP site sends to you. The cookies could then be read in a second curl invoke by using the -b/--cookie option! When used on FTP, the ftp server response lines are considered being "headers" and thus are saved there. If this option is used several times, the last one will be used.

To submit a form:

Code:
-d/--data <data> (HTTP) Sends the specified data in a POST request to the HTTP server, in a way that can emulate as if a user has filled in a HTML form and pressed the submit button. Note that the data is sent exactly as specified with no extra processing (with all newlines cut off). The data is expected to be "url-encoded". This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. Compare to -F. If more than one -d/--data option is used on the same command line, the data pieces specified will be merged together with a separating &-letter. Thus, using '-d name=daniel -d skill=lousy' would generate a post chunk that looks like 'name=daniel&skill=lousy'. If you start the data with the letter @, the rest should be a file name to read the data from, or - if you want curl to read the data from stdin. The contents of the file must already be url-encoded. Multiple files can also be specified. Posting data from a file named 'foobar' would thus be done with "--data @foo- bar". To post data purely binary, you should instead use the --data- binary option. -d/--data is the same as --data-ascii. If this option is used several times, the ones following the first will append data.
All this and more are in the man pages for curl. On the command line type "man curl" for all the details.
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 05:42 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,