Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
daprofiler
GitHub Repository: daprofiler/DaProfiler
Path: blob/main/modules/diplomes/last_diplomes.py
235 views
1
import requests
2
from bs4 import BeautifulSoup
3
4
def last_diplomes_bac(name,pren):
5
url = f'https://resultats.etudiant.lefigaro.fr/resultats-bac/recherche?name={pren} {name}&city_label=&city_insee='
6
r = requests.get(url)
7
page = r.content
8
features = "html.parser"
9
soup = BeautifulSoup(page, features)
10
profiles = soup.find_all('td',{'class':'svelte-11did2l'})
11
listt = []
12
for i in profiles:
13
if len(listt) == 1:
14
subject = listt[0]
15
link = "https://resultats.etudiant.lefigaro.fr"+subject.split('href="')[1].split('">')[0]
16
17
academie = None
18
mention = None
19
ville = None
20
diplome = None
21
22
r = requests.get(link)
23
page = r.content
24
features = "html.parser"
25
soup = BeautifulSoup(page, features)
26
27
mention = soup.find('span',{'class':'block text-4xl text-red'}).text.split('"')[1].split('"')[0]
28
diplome = soup.find('p',{'class':'text-grey-600 mb-1'}).text.strip()
29
academie = soup.find('div',{'class':'flex flex-col items-center sm:flex-row flex-wrap gap-5'}).text.split(',')[1].strip()
30
city = soup.find('a',{'class':'capitalize underline'}).text.strip()
31
32
json_output = {
33
'Exists':True,
34
'academie':academie,
35
'Link':link,
36
'mention':mention,
37
'ville':city,
38
'Diplome':diplome
39
}
40
return json_output
41
elif len(listt) == 0:
42
profile = str(i).lower()
43
if pren.lower() in profile and name.lower() in profile:
44
listt.append(profile)
45
46
47
def last_diplomes_brevet(name,pren):
48
url = f'https://resultats.etudiant.lefigaro.fr/resultats-brevet/recherche?name={pren} {name}&city_label=&city_insee='
49
r = requests.get(url)
50
page = r.content
51
features = "html.parser"
52
soup = BeautifulSoup(page, features)
53
profiles = soup.find_all('div',{'class':'bg-white p-2'})
54
for i in profiles:
55
profile = str(i).lower()
56
if pren.lower() in profile and name.lower() in profile:
57
url = "https://resultats.etudiant.lefigaro.fr"+profile.split('href')[1].split('"')[1]
58
r = requests.get(url)
59
page = r.content
60
features = "html.parser"
61
soup = BeautifulSoup(page, features)
62
63
profile = soup.find('div',{'class':'box'})
64
mention = soup.find('span',{'class':'block text-4xl text-red'})
65
diplome = soup.find('p',{'class':'text-grey-600 mb-1'})
66
67
diplome = str(diplome).split('text-grey-600 mb-1">')[1].split('</p>')[0]
68
nom_prenom = str(profile).split('h1>')[1].split('<span')[0]
69
ville = str(profile).split('capitalize">')[1].split('</span>')[0]
70
academie = str(profile).split('(')[1].split(')')[0]
71
mention = str(mention).split('class="block text-4xl text-red">')[1].split('</span>')[0]
72
73
74
json_output = {
75
'Exists':True,
76
"Name":nom_prenom.strip(),
77
'academie':academie,
78
'Link':url,
79
'mention':mention,
80
'ville':ville,
81
'Diplome':diplome
82
}
83
return json_output
84
85