I'd like to start my own cURL UDF, with a focus on a nice and simple syntax. There are many other cURL samples in the forum, though I found them too difficult to understand and use.
This UDF uses the libcurl library, as opposed to the cURL command-line tool, to provide better integration with AutoIT and better performance.
REQUIREMENTS:
- Windows 32-bit (not tested under Windows 64-bit but may work if a 64-bit version of libcurl below is used)
- AutoIt3 3.2 or higher
- libcurl v7.21.7 or higher (libcurl.dll, libeay32.dll & libssl32.dll) - see http://curl.haxx.se or download link below
EXAMPLES:cURL_initialise()
cURL_easy($url, $cookie_file = "", $cookie_action = 0, $output_type = 0, $output_file = "", $postfields = "", $ssl_verifypeer = 0, $noprogress = 1, $followlocation = 0, $http_headers = "")
cURL_multi($url, $cookie_file = "", $cookie_action = 0, $output_type = 0, $output_file = "", $postfields = "", $ssl_verifypeer = 0, $noprogress = 1, $followlocation = 0, $http_headers = "")
cURL_cleanup()
Note - To make these examples work, you must make sure the three libcurl DLLs (libcurl.dll, libeay32.dll & libssl32.dll) are present in the same folder as the examples.
Example #1 - Reading HTML from a webpage.
#include <cURL.au3> ; Initialise cURL cURL_initialise() ; Return the HTML from "http://www.autoitscript.com/site" $out = cURL_easy("http://www.autoitscript.com/site/") ; Output the HTML to the console ConsoleWrite($out) ; Clean up cURL cURL_cleanup()
Example #2 - Reading a binary file from a website.
#include <cURL.au3> ; Initialise cURL cURL_initialise() ; Output the file from "http://web.aanet.com.au/seangriffin/content/computing/development/eBay%20Bargain%20Hunter%20setup.exe" to "tmp.exe" cURL_easy("http://web.aanet.com.au/seangriffin/content/computing/development/eBay%20Bargain%20Hunter%20setup.exe", "", 0, 1, "tmp.exe") ; Clean up cURL cURL_cleanup()
Example #3 - Reading HTML from a webpage, and writing the cookie to a file.
#include <cURL.au3> ; Initialise cURL cURL_initialise() ; Return the HTML from "http://www.about.com", and the cookie to the file "cookie.txt" $out = cURL_easy("http://www.about.com", "cookie.txt", 2) ; output the HTML to the console ConsoleWrite($out) ; Clean up cURL cURL_cleanup()
DOWNLOAD:
Recent Version of libcurl.dll, libeay32.dll & libssl32.dll (required)
http://fossies.org/windows/www/curl-7.24.0-ssl-sspi-zlib-static-bin-w32.zip
Latest Version - v0.5 (03/04/12)
cURL.au3 17.53KB
738 downloads
Edited by seangriffin, 03 April 2012 - 04:05 AM.




