![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| lpr- how to print from page to page | naamas03 | Shell Programming and Scripting | 4 | 12-26-2007 03:30 AM |
| scp-1.2.27 man page | Tornado | Linux | 4 | 03-16-2007 05:09 AM |
| Fetching file from windows server | rochitsharma | UNIX for Advanced & Expert Users | 5 | 08-19-2006 06:51 AM |
| map Page Down and Page up to ] and [ | buddy_amazing | AIX | 0 | 03-01-2005 11:34 AM |
| PHP:page.php?id= ???? | perleo | Shell Programming and Scripting | 1 | 10-01-2003 06:29 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
fetching a web page in C
Hello,
I'm a total newbie to HTTP commands, so I'm not sure how to do this. What I'd like is to write a C program to fetch the contents of a html page of a given address. Could someone help with this? Thanks in advance! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
what I could immediately think of is
use ( wget url ) in a system with contents redirected to a file. But this is the not right approach. Else frame a http request and post it to the port 80 of the needed url |
|
#3
|
|||
|
|||
|
You basically do
Code:
fd=socket(AF_INET,SOCK_STREAM,0);
connect(fd,remoteWebserver....)
send(fd,"GET / HTTP/1.0\r\n\r\n",18);
shutdown(fd,SD_SEND);
while ((i=recv(fd,buf,sizeof(buf),0))>0)
{
write(1,buf,i);
}
close(fd);
|
|
#4
|
|||
|
|||
|
You can deal with https by using OpenSSL to provide the TCP connectivity.
|
|
#5
|
|||
|
|||
| Google The UNIX and Linux Forums |