From 22731602f6f5828334a612f428d70309d156c277 Mon Sep 17 00:00:00 2001 From: luandalmazo <luandalmazo@gmail.com> Date: Mon, 11 Jul 2022 09:23:49 -0300 Subject: [PATCH 1/2] add script to search --- main.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..fdc9f72 --- /dev/null +++ b/main.py @@ -0,0 +1,33 @@ +#Script made for searching for a specific word [search] in API. +#OBS: This script takes a long time to run. +import requests + +#The first learning_object begins at ID = 3 +id=3 + +NUM_OF_LEARNING_OBJECTS = 300000 +API_URL = 'https://api.portalmec.c3sl.ufpr.br/v1/learning_objects/' +ATTRIBUTE_FOR_SEARCH = 'name' + +search = input() + +while ( id<NUM_OF_LEARNING_OBJECTS ): + + try: + response = requests.get(API_URL+ str(id)) + data = response.json() + + if ( data[ATTRIBUTE_FOR_SEARCH].find(search) != -1 ): + print(data[ATTRIBUTE_FOR_SEARCH]) + + id+=1 + except: + id+=1 + +print("Finalizado") + + + + + + -- GitLab From d0c5f5aaa79b44984b26f369097c7bf4f5ba698c Mon Sep 17 00:00:00 2001 From: luandalmazo <luandalmazo@gmail.com> Date: Mon, 11 Jul 2022 09:26:08 -0300 Subject: [PATCH 2/2] add script to search --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index fdc9f72..be3f3c7 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,4 @@ -#Script made for searching for a specific word [search] in API. +#Script made to search for a specific word [search] in API. #OBS: This script takes a long time to run. import requests -- GitLab