Skip to content
Snippets Groups Projects
Commit b3e25ea6 authored by Georges Gressot's avatar Georges Gressot :speech_balloon:
Browse files

this one maybe

parent a10f9bc8
Branches
No related merge requests found
%% Cell type:code id: tags:
```
# @title String fields
Nom_du_labo = '' # @param {"type":"string","placeholder":"Par exemple : isis"}
Code_labo = '' # @param {"type":"string","placeholder":"Par exemple : 207480"}
# @title Date fields
Date_de_début = '2016-01-01' # @param {type:"date"}
Date_de_fin = '' # @param {type:"date"}
import datetime
x = datetime.datetime.now()
end_year = str(x.year)
code = "Enter your HAL lab code and submit : " # Assign a value to the variable 'code'
c = input(code) # Now, 'code' is defined and can be used within the input() function
url = "https://api.archives-ouvertes.fr/search/UNIV-STRASBG/?fq=structId_i:"\
+ c + "&rows=20000&wt=csv&fq=publicationDate_tdate:[2016-01-01T00:00:00Z%20\
TO%20" + end_year + "-12-31T00:00:00Z]&fq=doiId_s:[%22%22%20TO%20*]&fl=doiId_s"
print("Cliquez sur le lien suivant pour obtenir votre extraction : {}".format(url))
exit()
```
%% Output
Enter your HAL lab code and submit : leerlk
Cliquez sur le lien suivant pour obtenir votre extraction : https://api.archives-ouvertes.fr/search/UNIV-STRASBG/?fq=structId_i:leerlk&rows=20000&wt=csv&fq=publicationDate_tdate:[2016-01-01T00:00:00Z%20 TO%202024-12-31T00:00:00Z]&fq=doiId_s:[%22%22%20TO%20*]&fl=doiId_s
%% Cell type:code id: tags:
```
import requests
import io
import pandas as pd
# The API endpoint
url = "https://api.archives-ouvertes.fr/search/UNIV-STRASBG/?fq=structId_i:" + \
Code_labo + "&rows=20000&wt=csv&fq=publicationDate_tdate:%5B" + Date_de_début +\
"T00:00:00Z%20TO%20" + Date_de_fin + "T00:00:00Z%5D&fq=-doiId_s"
# A GET request to the API
response = requests.get(url)
df = pd.read_csv(io.StringIO(response.text))
try:
test = df.halId_s
print("Cliquez sur le lien suivant pour télécharger votre extraction : {}".format(url))
except:
print("Vérifiez vos saisies ou recommencez plus tard.")
exit()
```
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment