View Full Version : Get Url Code In C
guepard53
05-12-2004, 12:54 PM
Hi everybody ! :D
First, I've to say that English is not my motherlanguage...
This is my problem :
I want to get the source of a web page (with the URL of this page). I can do that with the 'urlmon.h' library in Visual C++ (works only for windows).
Does anybody know commands like 'InternetOpen, InternetOpenUrl, ... ' (used in urlmon.h) that works with Linux ?
I've red that I can use sockets to do that but I don't understand how to use it...
Thanks to help me ! :roll:
RobSeace
05-12-2004, 01:08 PM
There are a variety of libraries you can download which will allow
you to easily access data via HTTP/etc., without needing to do all
of the protocol handling yourself... One good one, which handles
damn near every protocol in existence is libcurl (http://curl.haxx.se/libcurl/)...
guepard53
05-12-2004, 02:09 PM
Thanks RobSeace ! :D
guepard53
05-12-2004, 02:33 PM
I use de curl.h library but I've some errors : undifined reference to curl_easy_init(), curl_easy_setopt(), curl_easy_perform(), ...
My GCC recognize my curl.h because there's no error for CURL *curl declaration.
Here's my code :
11 #include <stdio.h>
12 #include <curl/curl.h>
13
14 int main(void)
15 {
16 CURL *curl;
17 CURLcode res;
18
19 curl = curl_easy_init();
20 if(curl) {
21 curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se");
22 res = curl_easy_perform(curl);
23
24 /* always cleanup */
25 curl_easy_cleanup(curl);
26 }
27 return 0;
28 }
What is my error ? :roll:
Seems you have forgotten to link the library the .h file is for. The missing
reference kind of error is a linker error, not a compiler one. So you have
to make sure the library is linked to your executable.
Just don't ask me how that works with the libcurl thingy. I too can't make
much out of their manual. It's a bit on the strange side.
RobSeace
05-12-2004, 10:16 PM
Yeah, you need to add "-lcurl" to your link command-line...
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.