Skip to content

Instantly share code, notes, and snippets.

@XoLinA
Created February 11, 2026 20:09
Show Gist options
  • Select an option

  • Save XoLinA/3d3932721ac9edb0d6e46c2976a667be to your computer and use it in GitHub Desktop.

Select an option

Save XoLinA/3d3932721ac9edb0d6e46c2976a667be to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <windows.h>
#pragma comment(lib, "urlmon.lib")
using namespace std;
int main() {
string city[10] = {"Kyiv","Lviv","Odesa","Kharkiv","Dnipro","Zaporizhzhia","Vinnytsia","Poltava","Chernihiv","Ivano-Frankivsk"};
for (int i = 0; i < 10; i++)
{
string srcURL = "https://wttr.in/" + city[i];
const char* destFile = "weather.txt";
if (S_OK == URLDownloadToFileA(NULL, srcURL.c_str(), destFile, 0, NULL));
FILE* f;
fopen_s(&f, destFile, "r");
if (!f) {
cout << "File open error\n";
return 1;
}
char text[500];
while (fgets(text, sizeof(text), f))
{
string line = text;
size_t pos = line.find("<span class=\"ef050\">");
if (pos < line.length()) {
size_t start = line.find(">", pos) + 1;
size_t end = line.find("<", start);
string temp = line.substr(start, end - start);
cout << "\nTemperature in "<<city <<" : " << temp << endl;
break;
}
}
fclose(f);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment