Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: C++ & Html

  1. #1
    Junior Member
    Join Date
    Aug 2003
    Posts
    4

    C++ & Html

    Hello;
    I want to write a program that reads the source from a web site but i don't know which class/library to use. Any help would be appreciated... Thanx..

  2. #2
    Ok I couldn't find the Library for this I am artually kind of interested in this myself just for shits and giggles. But I did come up with a Program this might not be what your looking for though.

    I did a look and this is the thing that was really Close.(SP)

    http://www.newty.de/lsc/index.html

    Sorry First time I did it forgot to add the link.

  3. #3
    Member
    Join Date
    Oct 2003
    Posts
    78
    Try using fstream... I've never done it and don't have VC++ installed so you should:

    Code:
    #include <iostream>
    #include <fstream>//includes ifstream class for file  
    		     //input and ofstream class for file output
    using namespace std;
    
    int main ()
    {
    	ofstream fout; //creates an ofstream object named fout
    
    	fout.open("http://www.google.com");//fout opens the file "filename"
    	
    	fout << "I am writing in a file!";
    
    fout.close(); //closes the output connection to file //”filename.txt" (MS Word formatting is horrible, srry)
    
    	cout << "Press any key to end this program" << endl;
    	char x;
    	cin >> x;
    
    	return 0;
    }
    If that doesn't work, sorry, just a guess... but when/if you figure it out, post, I'd like to have some fun too.
    [pong][shadow]Why won\'t anyone give me greenies???[/shadow] [/pong]

  4. #4
    Senior Member
    Join Date
    May 2002
    Posts
    344
    lol hahaha omg talking about plagarism...Lol never seen something so funny. :-\ if you are going to copy some of the code out of one of my old tutorials and then post it at least tell the person that you didnt write up the code but you took it from one of my tutorials...Wow that code looked awefully familiar . Well i wont neg, but next time, please tell the person that you are using someone elses example. lol i m sitting here laughing my ass off...by the way for those who dont know what i am talking about the code :-\ posted is my code that i typed up for an AO tutorial that can be found and downloaded at http://www.antionline.com/showthread...hreadid=247364

    EDIT:
    by the way :-\ out of all the examples i had included in my tutorial you choose the wrong one you should have choosen the one that read all of the characters from the file "http://www.google.com" and then fouted them into the a file. anyways i dont know how to write a program that does this...maybe a fun little project...bah what the hell ill go do it now...
    Support your right to arm bears.


    ^^This was the first video game which i played on an old win3.1 box

  5. #5
    Member
    Join Date
    Oct 2003
    Posts
    78
    Yup.. except as you can see I changed a part of it... and I even corrected parts of it if you remember.. hehe

    And go ahead.. neg me.. make my day buddy...

    I actually just gave a random thing from your tutorial and changed the filename.txt to something else to show where it goes.... but the point was to use the fstream header..
    [pong][shadow]Why won\'t anyone give me greenies???[/shadow] [/pong]

  6. #6
    Senior Member
    Join Date
    May 2002
    Posts
    344
    //”filename.txt" (MS Word formatting is horrible, srry)
    that was the part that gave it away...i remember being all pissed off at Microsoft Word for moving my code around... lol i dont enjoy negging people, i just want you to know that plagarism is a criminal act and you can go to jail for it and especially dont do it when the person who you are plagarising's home page is www.antionline.com and he reads every post that has the words C++ in the subject line

    its all good...makes me feel proud that people actually read my tutorials and try to act like they wrote some of it
    Support your right to arm bears.


    ^^This was the first video game which i played on an old win3.1 box

  7. #7
    Member
    Join Date
    Oct 2003
    Posts
    78
    Copying that short part of code would not even get a court to listen to you....

    And I recommend you set homepage to www.java.sun.com .... its a whole lot better
    [pong][shadow]Why won\'t anyone give me greenies???[/shadow] [/pong]

  8. #8
    Senior Member
    Join Date
    Jan 2002
    Posts
    1,207
    Code:
    	fout.open("http://www.google.com");//fout opens the file "filename"
    There are at least two reasons why that won't work.

    1. You are trying to open Google's home page for writing.

    2. You are trying to use the iostream library for something which IT DOES NOT DO.

    There may well be a third party library which extends iostream into, say httpistream, which can fetch files from URLs. But ifstream can't (And ofstream DEFINITELY can't)

    Slarty

  9. #9
    Junior Member
    Join Date
    Aug 2003
    Posts
    4
    As slarty said, this doesn't work. When i search for what i was looking for in CodeGuru and these kind of sites, i came into WinSock APIs and WinHTTP & WININET libraries. But i couldn't find any information how to fetch a web site. (I'm thinking about myself being dumb). Thanx anyway, at least people answer and try to help.

  10. #10
    just use sockets (winsock in windows, all those libraries in *nix) to connect to the server and read in the webpage. this is an extremely easy program to write if you are familiar with socket programming.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •