UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » Get Url Code In C

#1 2004-05-12 12:54 PM

guepard53
Member
Registered: 2004-05-12
Posts: 6

Re: Get Url Code In C

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:


Guépard

Offline

#2 2004-05-12 01:08 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: Get Url Code In C

Offline

#3 2004-05-12 02:09 PM

guepard53
Member
Registered: 2004-05-12
Posts: 6

Re: Get Url Code In C

Thanks RobSeace !  :D


Guépard

Offline

#4 2004-05-12 02:33 PM

guepard53
Member
Registered: 2004-05-12
Posts: 6

Re: Get Url Code In C

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:


Guépard

Offline

#5 2004-05-12 06:29 PM

Nope
Administrator
From: Germany
Registered: 2004-01-24
Posts: 385
Website

Re: Get Url Code In C

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.

Offline

#6 2004-05-12 10:16 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: Get Url Code In C

Yeah, you need to add "-lcurl" to your link command-line...

Offline

  • Index
  • » C
  • » Get Url Code In C

Board footer

Powered by FluxBB