Skip to content

Instantly share code, notes, and snippets.

@XoLinA
Created April 23, 2026 19:39
Show Gist options
  • Select an option

  • Save XoLinA/6346e1bb292eaf1d971e534e4f1fccab to your computer and use it in GitHub Desktop.

Select an option

Save XoLinA/6346e1bb292eaf1d971e534e4f1fccab to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <winhttp.h>
#include <iostream>
#include <string>
#pragma comment(lib, "winhttp.lib")
using namespace std;
string getHoroscope(string sign)
{
string result = "";
HINTERNET hSession = WinHttpOpen(L"Horoscope App",WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,WINHTTP_NO_PROXY_NAME,WINHTTP_NO_PROXY_BYPASS, 0);
HINTERNET hConnect = WinHttpConnect(hSession,L"ohmanda.com", INTERNET_DEFAULT_HTTPS_PORT, 0);
wstring path = L"/api/horoscope/" + wstring(sign.begin(), sign.end());
HINTERNET hRequest = WinHttpOpenRequest(hConnect, L"GET", path.c_str(),NULL, WINHTTP_NO_REFERER, WINHTTP_DEFAULT_ACCEPT_TYPES, WINHTTP_FLAG_SECURE);
WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0, WINHTTP_NO_REQUEST_DATA, 0,0, 0);
WinHttpReceiveResponse(hRequest, NULL);
DWORD dwSize = 0;
do {
DWORD dwDownloaded = 0;
WinHttpQueryDataAvailable(hRequest, &dwSize);
if (!dwSize)
break;
char* buffer = new char[dwSize + 1];
ZeroMemory(buffer, dwSize + 1);
WinHttpReadData(hRequest, (LPVOID)buffer, dwSize, &dwDownloaded);
result.append(buffer, dwDownloaded);
delete[] buffer;
}
while (dwSize > 0);
WinHttpCloseHandle(hRequest);
WinHttpCloseHandle(hConnect);
WinHttpCloseHandle(hSession);
return result;
}
int main()
{
string signs[] = {"aries","taurus","gemini","cancer","leo","virgo","libra","scorpio","sagittarius","capricorn","aquarius","pisces"};
cout << "************************************* HOROSCOPE *********************************\n\n";
cout << "Choose sign:\n";
for (int i = 0; i < 12; i++)
{
cout << i + 1 << ". " << signs[i] << endl;
}
int choice;
cin >> choice;
if (choice < 1 || choice > 12)
{
cout << "Error\n";
return 0;
}
string sign = signs[choice - 1];
cout << "\nStars-loading...\n";
string response = getHoroscope(sign);
cout << "\nResult:\n";
cout << response << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment