Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,907 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,200 people online right now. Registration is fast and FREE... Join Now!




C++ CGI?

 
Reply to this topicStart new topic

C++ CGI?, getting content from a webpage

thejasper
3 Jan, 2008 - 02:42 PM
Post #1

New D.I.C Head
*

Joined: 2 Nov, 2007
Posts: 28


My Contributions
Hallo

IK zou graag informatie van een webpagina kunnen opvragen om te gebruiken in m'n programma (C++ of C#). Maar ik heb eigenlijk geen idee of dit wel kan, het is geen RSS feed (hiervan vond ik een tutorial). Ik las ook wat over C++ CGI, daarmee kan je C++ (of bv ook perl en andere) programma's maken die draaien op een webpagina (corrigeer me als ik mis ben). Maar kun je hiermee ook gegevens opvragen, verwerken en dan eventueel terugzetten in een form? Met PHP kan dat maar het moet met C++ of C#

Of bestaan er hier speciale headerfiles voor om te includen? Wie weet raad? tongue.gif

alvast bedankt, jasper stupid.gif

This post has been edited by thejasper: 3 Jan, 2008 - 03:35 PM
User is offlineProfile CardPM
+Quote Post

jjhaag
RE: C++ CGI?
3 Jan, 2008 - 02:51 PM
Post #2

me editor am smartastic
Group Icon

Joined: 18 Sep, 2007
Posts: 1,789



Thanked: 2 times
Dream Kudos: 775
Expert In: C,C++

My Contributions
hmm...

In spite my last name, my Dutch is a little rusty, and there was never a point when it was good enough for technical work. All I've been able to figure out is that you're asking something about pulling webpage info into a C#/C++ program.

Although we're pretty international here, you'll probably have a lot better luck if you post in English. You might get lucky and have some expert who speaks your native tongue wander by, but I wouldn't count on it. Sorry sad.gif


*edit - Babel Fish provides us with this...but Babel Fish rarely knows what it's talking about, so we could still use some clarification:
QUOTE(Babel Fish @ 3 Jan, 2008 - 3:53 PM)

I information of a web page will be able ask to use in my programme (c ++ or c #). but I has in fact no idea or this, however, is possible, it is no RSS feed (of this I found tutorial). I read also what concerning c ++, with that is possible CGI you c ++ (or e.g. also perl and other) programmes makes those turns on a web page (correct me if I miss be). But can you ask also data, process and then possibly put back in a form? With PHP is possible that but it must with c ++ or c #


This post has been edited by jjhaag: 3 Jan, 2008 - 02:55 PM
User is offlineProfile CardPM
+Quote Post

thejasper
RE: C++ CGI?
3 Jan, 2008 - 03:02 PM
Post #3

New D.I.C Head
*

Joined: 2 Nov, 2007
Posts: 28


My Contributions
oh sorry, i completely forgot I had to write in English, sorry, I will rewrite it so everyone can read it
User is offlineProfile CardPM
+Quote Post

thejasper
RE: C++ CGI?
3 Jan, 2008 - 03:07 PM
Post #4

New D.I.C Head
*

Joined: 2 Nov, 2007
Posts: 28


My Contributions
Hello

I want to know how I can get content from a webpage to use in my C++ or C# program. But actually I have no idea if that's possible, it's no RSS feed. I read something about C++ CGI, with that you can make programs that run on a server and that are displayed on a webpage (correct me if I am wrong). But can you also get content from a webpage with that, do some stuff with the information and maybe put it back on a form? I know that's possible with PHP but I want to get it with C++ or C#..

Maybe there excist special header files to include? Who knows something to help me?

Thx
Jasper
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: C++ CGI?
3 Jan, 2008 - 05:23 PM
Post #5

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,351



Thanked: 51 times
Dream Kudos: 25
My Contributions
This can easily be done with C#

http://zamov.online.fr/EXHTML/CSharp/CSharp1.html

User is online!Profile CardPM
+Quote Post

Sacky
RE: C++ CGI?
3 Jan, 2008 - 06:47 PM
Post #6

New D.I.C Head
*

Joined: 28 Dec, 2007
Posts: 26

Funnily enough I just made a function that uses HTTP sockets to get raw HTML from sites, here is the code I used:

CODE
char* cDomain = "www.sa-mp.com";
char* cFile = "index.php";
char* cResult = (char*) malloc(10000*sizeof(char));
for(int i=0;i<10000;i++) cResult[i] = '\0';
SOCKET sSocket;
if((sSocket = socket(AF_INET,SOCK_STREAM,0)) != INVALID_SOCKET)
{
    sockaddr_in sockAddr;
    sockAddr.sin_family = AF_INET;
    sockAddr.sin_port = htons(80);
    #if defined WIN32
    HOSTENT *hResolve;
    #else
    struct hostent *hResolve;
    #endif
    if((hResolve = gethostbyname(cDomain)) != NULL)
    {
        sockAddr.sin_addr.s_addr = *((unsigned long*)hResolve->h_addr);
        if(!(connect(sSocket,(struct sockaddr*)&sockAddr,sizeof(sockAddr))))
        {
            sprintf(cResult,"GET /%s HTTP/1.1\r\nHost: %s\r\n\r\n",cFile,cDomain);
            send(sSocket,cResult,(int)strlen(cResult),0);
            recv(sSocket,cResult,10000*sizeof(char),0);
            recv(sSocket,cResult,10000*sizeof(char),0);
            amx_SetString(cPtr,cResult,false,false,params[4]);
            closesocket(sSocket);
            free(cResult);
            return true;
        }
        else printf("Could not connect to Domain");
    }
    else printf("Invalid Domain");
}
else printf("Invalid Socket");
closesocket(sSocket);
free(cResult);


You may have to adjust the HTTP Heading Packet but it works ok from my testing.
User is offlineProfile CardPM
+Quote Post

thejasper
RE: C++ CGI?
4 Jan, 2008 - 05:42 AM
Post #7

New D.I.C Head
*

Joined: 2 Nov, 2007
Posts: 28


My Contributions
I think the C# solution will do it best and easiest, thx for the answers wink2.gif I will try it out now
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 01:26PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month