Is there any library to get/fetch a remote URL?

C

Christopher Benson-Manica

Francesco Moi said:
I would like to fetch a remote URL by using C and get its
contents:
myfile = get("http://www.foo.com/foo.html")
Does exist any C library?

Not in standard C. If you're using *nix and wget is installed, you
might be able to do something like

system( "wget http://www.foo.com/foo.html" );

and then open the file with fopen() and proceed from there.

http://www.ungerhu.com/jxh/clc.welcome.txt
http://www.eskimo.com/~scs/C-faq/top.html
http://benpfaff.org/writings/clc/off-topic.html
 
K

Keith Thompson

I would like to fetch a remote URL by using C and get its
contents:
myfile = get("http://www.foo.com/foo.html")

Does exist any C library?

There is no portable way to do this. For non-portable solutions,
consult your system documentation or, if that fails, ask in a
newsgroup specific to your system.

<OT>
On Unix-like systems, you might consider invoking the "wget" program
with appropriate arguments. Note that "wget" may or may not be
installed on a given system.
</OT>
 
K

Keith Thompson

Christopher Benson-Manica said:
Not in standard C. If you're using *nix and wget is installed, you
might be able to do something like

system( "wget http://www.foo.com/foo.html" );

and then open the file with fopen() and proceed from there.

Frankly, this is a good example of why it's best not to go into too
much detail when giving hints about system-specific solutions. Anyone
using this solution would have to be aware of the fact that wget by
default writes its file to the current directory, which might be
unwritable or nonexistent, or which might already have a file of the
same name. Such concerns are off-topic here, but perfectly
appropriate in one of the Unix groups such as comp.unix.programmer.
 
C

Christopher Benson-Manica

Keith Thompson said:
Frankly, this is a good example of why it's best not to go into too
much detail when giving hints about system-specific solutions.

<ot>Well, obviously I didn't go into those details, did I? I
appreciate your concerns, but I don't think any great damage was done
by casually suggesting a possible solution along with the OT message
and links to the relevant clc documents.</ot>
 
F

Francesco Moi

Joona I Palaste said:
What's wrong with the answer already given by Jacob Navia?

The answer is not related with "Standard C".

I thank the help, but I'm looking for another solution...
 
R

Richard Bos

The answer is not related with "Standard C".

I thank the help, but I'm looking for another solution...

There is no ISO C answer. Jacob's answer is likely not of use to you
either, unless you're willing to lock yourself into his libraries, and
the way he's been talking about them here make me think that that would
be inadvisable. However, if you're able to use POSIX extensions (which,
if you've got a system capable of using HTTP like that, is quite
likely), comp.unix.programmer might be able to provide you with an
answer.

Richard
 
I

Ilja Booij

There is no portable way to do this. For non-portable solutions,
consult your system documentation or, if that fails, ask in a
newsgroup specific to your system.

<OT>
On Unix-like systems, you might consider invoking the "wget" program
with appropriate arguments. Note that "wget" may or may not be
installed on a given system.
</OT>

You might want to try libcURL. In my experience, it's quite a nice
library, which is available for lots of platforms.

The url for curl (command-line program) and libcurl (the library)
is http://curl.haxx.se/

Cheers,
Ilja
 
F

Francesco Moi

Artie Gold said:
<rant>
THEN THE QUESTION DOESN'T BELONG HERE!


Indeed.

--ag

The answer I'm trying to find IS RELATED with "Standard C"
The answer given by Jacob Navia IS NOT RELATED with "Standard C".
 
J

Joona I Palaste

Francesco Moi said:
The answer I'm trying to find IS RELATED with "Standard C"
The answer given by Jacob Navia IS NOT RELATED with "Standard C".

The fact is, it is *IMPOSSIBLE* within the limits of Standard C to fetch
the contents of an URL, or to do anything else with the Internet or
other networking at all, for that matter. So Non-Standard C answers are
the best you're going to get.
Therefore I suggest you either start asking for platform-specific help
on platform-specific newsgroups (not on comp.lang.c) or forget about
the entire thing.
 
M

Mark McIntyre

The answer I'm trying to find IS RELATED with "Standard C"

Yes, and you've already had an answer: "This can't be done in Standard C".
You need to carefully read all replies, even the ones you don't like.
The answer given by Jacob Navia IS NOT RELATED with "Standard C".

Indeed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top