Commit 2236e91c authored by Emil Bordin's avatar Emil Bordin
Browse files

R Script angepasst

parent b5f53430
Loading
Loading
Loading
Loading
+2 −21
Original line number Diff line number Diff line
@@ -21,25 +21,6 @@ unnest_dataframes <- function(x) {
  return(y)
}

# Funktion zum Anfordern des Tokens
get_token <- function() {
  headers <- c("Content-Type" = 'application/x-www-form-urlencoded')
  
  data <- list(
    client_id = 'c003a37f-024f-462a-b36d-b001be4cd24a',
    client_secret = '32a39620-32b3-4307-9aa1-511e3d7f48a8',
    grant_type = 'client_credentials'
  )
  
  res <- POST(url = 'https://rest.arbeitsagentur.de/oauth/gettoken_cc',
              add_headers(.headers = headers),
              body = data,
              encode = 'form')
  
  token <- content(res)$access_token
  return(token)
}

# Funktion zum Herunterladen aller Jobs
download_all_jobs <- function(searchterm, location, radius) {
  token <- get_token()
@@ -165,7 +146,7 @@ conditional_save_downloads <- function(subfolder, jobs, refid_active_jobs = NULL
  today_wday <- wday(today_date)
  
  # Pfad des Unterordners erstellen
  base_path <- "C:/Users/Surface/git/ids_2024_thas_public/01_data/downloads"
  base_path <- "Gruppe_11/aidaho_ids_thas/01_data/downloads"
  subfolder_path <- file.path(base_path, subfolder)
  
  # Sicherstellen, dass der Unterordner existiert, ansonsten erstellen
@@ -225,7 +206,7 @@ conditional_save_downloads <- function(subfolder, jobs, refid_active_jobs = NULL
all_jobs <- download_all_jobs("Daten", "Stuttgart", 100)

# Aktive Jobs ermitteln
active_jobs <- get_active_jobs("01_data/downloads")
active_jobs <- get_active_jobs("Gruppe_11/aidaho_ids_thas/01_data/downloads")

# Downloads bedingt speichern
conditional_save_downloads("00_jobs_searchterm", all_jobs, active_jobs, "daten")