Hi!
How can I get information from a public web page to my program?
The page has, among other information, a field like "Share price: ###" that will be changing in time, and I want the program to get all the changes in its value.
Anyone has any idea?
Thanks a lot.

or you could use the non-viral libcurl. http://curl.haxx.se/libcurl/

#include <curl/curl.h>
#include <iostream>
#include <algorithm>
#include <iterator>

struct stats
{
  stats() : bytes_recd(0), ncalls(0) {}
  int bytes_recd ;
  int ncalls ;
};

size_t on_data( void* buffer, size_t size, size_t nmemb, 
                void* pv )
{
 size_t nbytes = size * nmemb ;
 const char* chars = static_cast<const char*>(buffer) ;

 std::copy( chars, chars+nbytes,
        std::ostream_iterator<char>(std::cout) ) ;

 static_cast<stats*>( pv )->bytes_recd += nbytes ;
 ++ static_cast<stats*>( pv )->ncalls ;

 return nbytes ;
}

int main()
{
  stats statistics ;

  CURL* handle = curl_easy_init() ;
  curl_easy_setopt( handle, CURLOPT_URL, 
                    "http://curl.haxx.se/libcurl/") ;
  curl_easy_setopt( handle, CURLOPT_WRITEFUNCTION, on_data ) ;
  curl_easy_setopt( handle, CURLOPT_WRITEDATA, &statistics ) ;

  curl_easy_perform( handle ) ;

  std::cout << "\n--------------------------------------\n"
       << "received " << statistics.bytes_recd << " bytes in "
       << statistics.ncalls << " callbacks\n" ;
}

you need to link with libcurl:

>[B] g++ -Wall -std=c++98 -pedantic -Werror -I /usr/local/include -L /usr/local/lib -lcurl use_curl.cc && ./a.out[/B]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD> <TITLE>libcurl - the multiprotocol file transfer library</TITLE>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
// ...
// elided
// ...
<!-- last-line-in-body -->
</BODY>
</HTML>
--------------------------------------
received 10857 bytes in 21 callbacks
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.