I need to open a web page from c++

This is a discussion on I need to open a web page from c++ within the C++ Programming forums, part of the General Programming Boards category; Hello, I need to open a web page using c++( the only language I know) and preferably save the html ...

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    7

    I need to open a web page from c++

    Hello, I need to open a web page using c++( the only language I know) and preferably save the html as a text file. could any one help?

    I work for a company where i'm manually comparing a data base of addresses to a online county database of addresses. If i could only get the html on a text file(notepad) I could write the code to compare the names and addresses it would save me a lot of time. I just can't figure it out. thanks. Ray.

  2. #2
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    For opening a page, search the forums for ShellExecute(). (get the parameters from there)

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,077
    I don't think he's looking to open the page in a web browser, I think he's looking to just grab the HTML. This is easy enough to do, you just open a socket to the web page and read... then you just write what you read to a file.
    Sent from my iPadŽ

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,855
    Well you could use cURL or wget to grab the pages for you, then use your program to read text files.
    http://en.wikipedia.org/wiki/CURL

    Or you could use the library libcurl which comes with it, so you can write the code directly.

    Or you could use low level network programming and implement it all yourself.

    Or (assuming you're on windows since you said notepad), and that you're using some visual C++ compiler, how about using one of the M$ wrappers for network programming?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    7
    hmmm how do i open a socket and what are tags

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7,344
    That is SlyMaelstrom's signature, which appears below all his posts and asks users to use forum code tags when posting code. You aren't posting code right now, so ignore the signature (everything below the line in the posts).

    Also, you can edit your posts by clicking the edit button so you don't have to keep adding more posts.

  8. #8
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    Or, if you didn't want to get into curl -

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    
    #include <urlmon.h>
    #include <conio.h>
    
    
    #pragma comment( lib, "urlmon.lib" )	
    
    
    using namespace std;
    
    int main( void )
    {
    
    	HRESULT ReturnValue;
    
    	string	FromSite = "http://www.google.com/";
    	string	ToFile = "C:\\thing.php";
    
    	
    	ReturnValue = URLDownloadToFile(	NULL, 
    						FromSite.c_str(),
    						ToFile.c_str(), 
    						0, 
    						NULL );	
    
    	return 0;
    }
    Which depends on whether you have the headers required, obviously.
    Last edited by twomers; 09-27-2006 at 03:33 PM.

  9. #9
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,077
    By "work for a company"... I'm going to assume you don't mean as a programmer. If you know nothing about programming, then I suggest you use cURL or something similar as Salem suggested. If you are, in fact, and employed programmer then I personally think we've given you enough buzz words for you to figure this out yourself. But I will say that there is a Network Programming forum on this message board which has a sticky to several links about socket programming. Read up.
    Last edited by SlyMaelstrom; 09-27-2006 at 03:35 PM.
    Sent from my iPadŽ

  10. #10
    Registered User
    Join Date
    Sep 2006
    Posts
    7
    thanks

  11. #11
    Registered User
    Join Date
    Sep 2006
    Posts
    7
    Nope, not working as a programmer. i'm in my third C++ class now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. FYI: The main web site page got hacked.
    By Dino in forum A Brief History of Cprogramming.com
    Replies: 53
    Last Post: 04-30-2008, 05:22 AM
  2. Partial web page downloading
    By god_of_war in forum C++ Programming
    Replies: 12
    Last Post: 08-14-2006, 01:19 PM
  3. why page based I/O can improve performance?
    By George2 in forum C Programming
    Replies: 1
    Last Post: 06-12-2006, 08:42 AM
  4. virtual memory
    By sweets in forum C Programming
    Replies: 6
    Last Post: 11-06-2004, 06:55 AM
  5. Opening a web page
    By phantom in forum C++ Programming
    Replies: 8
    Last Post: 04-10-2004, 04:53 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21