Skip to content
This repository was archived by the owner on Jun 10, 2026. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up JDK 8.0
uses: actions/setup-java@v3
with:
java-version: '8.0'
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public class App

Обратиться через браузер на адрес **https://api.ipify.org/?format=json** и получить json-ответ, содержащий IP4-адрес клиента. Извлечь адрес и вывести на экран в виде строки.

# Задание №3
## Задание №3

Через сайт **https://open-meteo.com** получить прогноз погоды на сутки. Использовать в качестве местоположения координаты Нижнего Новгорода (56, 44).

Expand Down
32 changes: 32 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>ST7</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.15.0</version>
</dependency>

<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>

</dependencies>

</project>
26 changes: 26 additions & 0 deletions result/forecast.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
№ | Time | Temp | Rain
---------------------------
1 | 2026-06-07T00:00 | 9.4 | 0.0
2 | 2026-06-07T01:00 | 8.7 | 0.0
3 | 2026-06-07T02:00 | 8.1 | 0.0
4 | 2026-06-07T03:00 | 7.9 | 0.0
5 | 2026-06-07T04:00 | 8.0 | 0.0
6 | 2026-06-07T05:00 | 9.8 | 0.0
7 | 2026-06-07T06:00 | 13.4 | 0.0
8 | 2026-06-07T07:00 | 16.4 | 0.0
9 | 2026-06-07T08:00 | 18.5 | 0.0
10 | 2026-06-07T09:00 | 20.4 | 0.0
11 | 2026-06-07T10:00 | 21.1 | 0.0
12 | 2026-06-07T11:00 | 22.1 | 0.0
13 | 2026-06-07T12:00 | 23.3 | 0.0
14 | 2026-06-07T13:00 | 23.0 | 0.0
15 | 2026-06-07T14:00 | 23.6 | 0.0
16 | 2026-06-07T15:00 | 23.5 | 0.0
17 | 2026-06-07T16:00 | 23.6 | 0.0
18 | 2026-06-07T17:00 | 23.4 | 0.0
19 | 2026-06-07T18:00 | 23.0 | 0.0
20 | 2026-06-07T19:00 | 21.5 | 0.0
21 | 2026-06-07T20:00 | 19.0 | 0.0
22 | 2026-06-07T21:00 | 17.0 | 0.0
23 | 2026-06-07T22:00 | 15.4 | 0.0
24 | 2026-06-07T23:00 | 14.0 | 0.0
27 changes: 27 additions & 0 deletions src/main/java/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.example;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class App {

public static void main(String[] args) {

WebDriver webDriver = new ChromeDriver();

try {
webDriver.get("https://www.calculator.net/password-generator.html");

System.out.println("Task 1 opened");

Task2.run(webDriver);
Task3.run(webDriver);

} catch (Exception e) {
System.out.println("Error");
System.out.println(e);
} finally {
webDriver.quit();
}
}
}
32 changes: 32 additions & 0 deletions src/main/java/Task2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.example;

import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class Task2 {

public static void run(WebDriver driver) {

try {
driver.get("https://api.ipify.org/?format=json");

WebElement pre = driver.findElement(By.tagName("pre"));
String jsonText = pre.getText();

JSONParser parser = new JSONParser();
JSONObject obj = (JSONObject) parser.parse(jsonText);

String ip = (String) obj.get("ip");

System.out.println("\nTASK 2");
System.out.println("IP: " + ip);

} catch (Exception e) {
System.out.println("Task2 error");
System.out.println(e);
}
}
}
49 changes: 49 additions & 0 deletions src/main/java/Task3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.example;

import org.json.simple.JSONObject;
import org.json.simple.JSONArray;
import org.json.simple.parser.JSONParser;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class Task3 {

public static void run(WebDriver driver) {

try {
String url = "https://api.open-meteo.com/v1/forecast?latitude=56&longitude=44&hourly=temperature_2m,rain&timezone=Europe%2FMoscow&forecast_days=1";

driver.get(url);

WebElement pre = driver.findElement(By.tagName("pre"));
String jsonText = pre.getText();

JSONParser parser = new JSONParser();
JSONObject obj = (JSONObject) parser.parse(jsonText);

JSONObject hourly = (JSONObject) obj.get("hourly");

JSONArray time = (JSONArray) hourly.get("time");
JSONArray temp = (JSONArray) hourly.get("temperature_2m");
JSONArray rain = (JSONArray) hourly.get("rain");

System.out.println("\nTASK 3");
System.out.println("№ | Date/Time | Temp | Rain");
System.out.println("--------------------------------");

for (int i = 0; i < time.size(); i++) {
System.out.println(
(i + 1) + " | " +
time.get(i) + " | " +
temp.get(i) + " | " +
rain.get(i)
);
}

} catch (Exception e) {
System.out.println("Task3 error");
System.out.println(e);
}
}
}
Loading