I've googled for a while and found few things (I hate using external libs such as cURL) and I don't really have experience with HTTP, so the question is: how can I interact with websites using sockets? so something like this:
- I connect to the website
- I store value of variable, for example "var1" (on website) to my variable in the program "iVarValue"
- I type in iVarValue to the edit box with id "editbox1"
- I press button with id "button1"
so far I have only connection phase
#include <WinSock2.h>
#include <Windows.h>
#include <iostream>
using namespace std;
#pragma comment (lib, "ws2_32.lib")
int main()
{
WSADATA WsaData;
if(WSAStartup(MAKEWORD(2,2), &WsaData) != 0)
{
cout << "startup failed\n";
system("pause");
return 1;
}
SOCKET sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
struct hostent *host;
host = gethostbyname("www.google.com");
SOCKADDR_IN SockAddr;
SockAddr.sin_port = htons(80);
SockAddr.sin_family = AF_INET;
SockAddr.sin_addr.s_addr = *((unsigned long*)host->h_addr);
cout << "Connecting\n";
if(connect(sock, (SOCKADDR*)(&SockAddr), sizeof(SockAddr)) != 0)
{
cout << "Can't connect\n";
system("pause");
return 1;
}
cout << "Connected!\n";
closesocket(sock);
WSACleanup();
cout << endl;
system("pause");
return 0;
}
so how do I get the specific variable (not whole source code) and interact with windows?
Thanks