//flex table opened by JP

Click to See Complete Forum and Search --> : Webpage readin


Ram09
08-20-2002, 03:51 PM
Hello,

is it possible to read in a webpage in Dev C++?

that is take the url and open the page so that you can read in that page.
ex.
filename = "http://thispage.html";
ifstream infile(file_name.c_str());
and the file that is open is the webpage?

thanks for your help

Ram09

Quandary
08-20-2002, 04:14 PM
Yes and no.

The fast answer is just no.

The long answer:
When you do a low-level open command, you are making a call to the OS that says "Open this file at this path." An http path is outside of the OS - you can't type in cd http://www.whatever.com/ at a c-prompt and expect to work. It is possible, however, to make remote procedure calls (though I believe that the calls are OS dependant). It *is* possible to open remote files, it just isn't as simple as trying to use the local operating system.

Start mucking around with TCP/IP and sockets and see what you can find. You can read data in through sockets, but you will probably have to figure out how the data is tranferred on specific protocols (HTTP/port 80, FTP/port 20 and 21 (data and control), etc.)

- Q

qball
08-21-2002, 01:27 AM
kinda like, this:

Ok, I know it's java code, just do same in C#, or ur, ah, that better language???


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

public class URLReader {
public static void main(String[] args) throws Exception {
URL yahoo = new URL("http://www.yahoo.com/");
BufferedReader in = new BufferedReader(
new InputStreamReader(
yahoo.openStream()));

String inputLine;

while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);

in.close();
}
}


Hint, change "URL" value.