// JP opened flex table

Click to See Complete Forum and Search --> : Download HTML code from some site. [C++]


KRUNCH
May 30th, 2008, 10:52 AM
So , i got a problem , im in some kind of a project , and im stuck with the networking part.Actualy my needs are low but im not a network programmer.
Im on linux so no visual c++ , no win complications or such.
What i need is just the shortest possible code that will:
Go to that site i put in the code and just read the html.

Pseudo code:
connect to site
while not site code end
{
getline
write output line
}
end

thanks in advance.

PS. yes i maid a few tries but its too stupid to post.I tried like the infput file name is
http://that site and such but i know it doesnt work so help out guys :D

ahoodin
May 30th, 2008, 11:58 AM
Sounds like you want to make a web spider of something. A creature that navigates the web. Some of them copy pages out of it like the Websnake software package.
http://arachnid.sourceforge.net/
http://www.searchtools.com/robots/robot-code.html

HTH,

KRUNCH
May 30th, 2008, 01:28 PM
Actualy this is like the complete oposite from what i said.All i need is a prog that opens a single page that just saves the source to a file.Just the function you have in every browser.
View page source and just copy/paste it. Id love to learn network programming. But i don't have the time , nor do i have the intention to ever do it seriously.This just came by ocasion and is nothing that cant be done in a minute manualy , but its solely for the purpose of being fully automated.
Oh and i dont need the complex spider/robots or whatever just plain html copy/paste program.Id appricite every help.


Thnaks for the links may come handy if i dacide to start network pogramming. ;)


EDIT:
Heres a java based one.And its exactly what i need except the part that its written in java. :D

import java.io.*;
import java.net.*;

public class SourceViewer{
public static void main (String[] args) throws IOException{
System.out.print("Enter url of local for viewing html source code: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String url = br.readLine();
try{
URL u = new URL(url);
HttpURLConnection uc = (HttpURLConnection) u.openConnection();
int code = uc.getResponseCode();
String response = uc.getResponseMessage();
System.out.println("HTTP/1.x " + code + " " + response);
for(int j = 1; ; j++){
String header = uc.getHeaderField(j);
String key = uc.getHeaderFieldKey(j);
if(header == null || key == null)
break;
System.out.println(uc.getHeaderFieldKey(j) + ": " + header);
}
InputStream in = new BufferedInputStream(uc.getInputStream());
Reader r = new InputStreamReader(in);
int c;
while((c = r.read()) != -1){
System.out.print((char)c);
}
}
catch(MalformedURLException ex){
System.err.println(url + " is not a valid URL.");
}
catch(IOException ie){
System.out.println("Input/Output Error: " + ie.getMessage());
}
}
}

ahoodin
May 30th, 2008, 04:37 PM
Well when you break the web spider down into basic components, that is what it does. Open a page, get the contents. So you dont really know what you want. No reason to post in such a headstrong manner. It's rude. Plus your example is sort of simple even for a simple programmer. If you dont want to learn network programming, perhaps you should consider getting someone who does to do your simple task. :cool:

ahoodin
May 30th, 2008, 04:43 PM
DIRTY WORK

Times are hard
You're afraid to pay the fee
So you find yourself somebody
Who can do the job for free
When you need a bit of lovin'
Cause your man is out of town
That's the time you get me runnin'
And you know I'll be around

CHORUS:
I'm a fool to do your dirty work
Oh yeah
I don't wanna do your dirty work
No more
I'm a fool to do your dirty work
Oh yeah

Light the candle
Put the lock upon the door
You have sent the maid home early
Like a thousand times before
Like the castle in its corner
In a medieval game
I foresee terrible trouble
And I stay here just the same

CHORUS

//JP added flex table