• R/O
  • SSH

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修訂9334aeefa44010274c72baa383cd21356c296c2d (tree)
時間2025-01-18 08:52:41
作者Lorenzo Isella <lorenzo.isella@gmai...>
CommiterLorenzo Isella

Log Message

A script to retrieve a json file from the api link of data.europa.eu.

Change Summary

差異

diff -r 86376ef1ac7b -r 9334aeefa440 R-codes/retrieve_json_europa.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/R-codes/retrieve_json_europa.R Sat Jan 18 00:52:41 2025 +0100
@@ -0,0 +1,21 @@
1+# Load necessary libraries
2+library(httr)
3+
4+# Function to download JSON from a URL with multiple tabs
5+download_json_from_url <- function(url, output_file = "results.json") {
6+ # Add headers to specify the type of content we want (JSON)
7+ response <- GET(url, add_headers(Accept = "application/json"))
8+
9+ # Check if the response status code is successful
10+ if (status_code(response) == 200) {
11+ # Save the JSON content to the specified file
12+ write(content(response, as = "text", encoding = "UTF-8"), file = output_file)
13+ message("JSON file saved to: ", output_file)
14+ } else {
15+ stop("Failed to download JSON content. Status code: ", status_code(response))
16+ }
17+}
18+
19+# Example usage
20+url_example <- "https://data.europa.eu/api/hub/search/datasets/f9c9501a-9821-4fde-9c53-993fe13dde78" # Replace with your JSON tab URL
21+download_json_from_url(url_example, "../output/test.json")