LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-22-2009, 11:38 AM   #1
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Rep: Reputation: 70
Simple web page retrieval in C


Hi all,

I am trying to find C source code for a program that accepts a URL as an argument and retrieves the html source it links to. Nothing fancy; no recursion or progress indication required nor a GUI. Something like a 'wget lite' if you will; ie, very simple. Any suggestions would be most welcome!

Thanks,
cc.
 
Old 10-22-2009, 12:52 PM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,781

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
If you don't mind a dependency on libcurl, try simple.c. The URL is hard coded, but it's a trivial change to accept a command line argument.
 
Old 10-22-2009, 01:08 PM   #3
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 115Reputation: 115
If you don't want a libcurl dependency, it's pretty simple to code up a HTTP client using TCP sockets. Open socket, push GET request through, pull data, close socket.
http://beej.us/guide/bgnet/

If it can be bash rather than C, there's a nifty three-liner example.
http://tldp.org/LDP/abs/html/devref1.html
 
Old 10-23-2009, 08:12 AM   #4
Completely Clueless
Member
 
Registered: Mar 2008
Location: Marbella, Spain
Distribution: Many and various...
Posts: 899

Original Poster
Rep: Reputation: 70
Allow me to augment your rather meagre thanks count, Tuxdev. :-)
Oh bugger. I've just noticed my ratio is even worse than yours!

Last edited by Completely Clueless; 10-23-2009 at 08:14 AM. Reason: spotted something
 
Old 10-23-2009, 11:57 AM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
snarf:
http://www.linux.org/apps/AppId_2052.html
It's alot smaller than wget & Co., though it handle ftp and the old gopher protocol.
 
  


Reply



Posting 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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
executing linux commands from web page and outputing it back to the web page ashes_sheldon Programming 9 02-28-2015 12:07 AM
How to write a simple C program in Linux to download a web page? rajeshcurl Linux - Software 3 04-09-2009 07:55 AM
simple script to grab an image from a web page and set background stardotstar Programming 43 09-11-2006 10:52 PM
Wireless Router D-Link DSL-G604T - intermittent web page retrieval on Fedora Core 4 shogunmike Linux - Wireless Networking 3 07-05-2005 01:29 AM
Web Page Retrieval & Processing with PERL BBQ_Matt Programming 3 10-25-2003 09:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration