Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -237,7 +237,6 @@ def datavisualisation_skills_context(df, template, paper_bgcolor, plot_bgcolor,
|
|
| 237 |
def datavisualisation_chiffres_cles_emplois(url):
|
| 238 |
response = requests.get(url)
|
| 239 |
soup = BeautifulSoup(response.text, "html.parser")
|
| 240 |
-
print("Le code HTML est : " + soup)
|
| 241 |
alldemandeurs = ''
|
| 242 |
allsalaires = ''
|
| 243 |
alldifficultes = ''
|
|
@@ -251,14 +250,12 @@ def datavisualisation_chiffres_cles_emplois(url):
|
|
| 251 |
allnumembauches = allnumembauches.replace(" ","").strip()
|
| 252 |
else:
|
| 253 |
allnumembauches = removeTags(allnumembauchesfirst[0]).replace(" ","").strip()
|
| 254 |
-
print("Embauches : " + allnumembauches)
|
| 255 |
if removeTags(allnumembauchesfirst[1]).find('\xa0') != -1:
|
| 256 |
allnumoffres = removeTags(allnumembauchesfirst[1]).split('\xa0')
|
| 257 |
allnumoffres = ''.join(allnumoffres)
|
| 258 |
allnumoffres = allnumoffres.replace(" ","").strip()
|
| 259 |
else:
|
| 260 |
allnumoffres = removeTags(allnumembauchesfirst[1]).replace(" ","").strip()
|
| 261 |
-
print("Offres : " + allnumoffres)
|
| 262 |
|
| 263 |
alldetailembauches = soup.select('p.hiring_text.ng-star-inserted')
|
| 264 |
allnumevolutionembauches = soup.select('p.main.ng-star-inserted')
|
|
@@ -276,7 +273,6 @@ def datavisualisation_chiffres_cles_emplois(url):
|
|
| 276 |
alldemandeurs += "</td>"
|
| 277 |
alldemandeurs += "<td>" + allnumoffres + "</td></tr>"
|
| 278 |
alldemandeurs += "</table>"
|
| 279 |
-
print("Rapport Offres / Demandeurs : " + alldemandeurs)
|
| 280 |
|
| 281 |
allFAP = soup.select('tr.sectorTable__line.ng-star-inserted')
|
| 282 |
allcategorie = soup.select('td.sectorTable__cell')
|
|
@@ -292,7 +288,6 @@ def datavisualisation_chiffres_cles_emplois(url):
|
|
| 292 |
allsalaires += "<tr><td>" + removeTags(alltypesalaires[2]) + "</td><td>" + removeTags(allcategorie[4]) + "</td><td>" + removeTags(allFAPsalaires[4]).replace('\xa0','').replace(' ','').replace('€','').replace(' ','').strip() + "</td></tr>"
|
| 293 |
allsalaires += "<tr><td>" + removeTags(alltypesalaires[3]) + "</td><td>" + removeTags(allcategorie[4]) + "</td><td>" + removeTags(allFAPsalaires[5]).replace('\xa0','').replace(' ','').replace('€','').replace(' ','').strip() + "</td></tr>"
|
| 294 |
allsalaires += "</table>"
|
| 295 |
-
print("Salaires : " + alldemandeurs)
|
| 296 |
|
| 297 |
alltypedifficultes = soup.select('.tabs-main-content_persp-col2-bar.ng-star-inserted')
|
| 298 |
alldifficulte = soup.select('p.horizontal-graph_title')
|
|
@@ -301,7 +296,6 @@ def datavisualisation_chiffres_cles_emplois(url):
|
|
| 301 |
for i in range(0,len(alltypedifficultes)):
|
| 302 |
alldifficultes += "<tr><td>" + removeTags(alldifficulte[i]) + "</td><td>" + removeTags(allpcdifficulte[i]).replace('Pour le territoire principal FRANCE pour les ' + removeTags(alldifficulte[i]),'').replace('%','').strip() + "</td></tr>"
|
| 303 |
alldifficultes += "</table>"
|
| 304 |
-
print("Difficultés : " + alldifficultes)
|
| 305 |
|
| 306 |
alltyperepartitions = soup.select('div.hiring-contract_legende_item.ng-star-inserted')
|
| 307 |
allrepartition = soup.select('p.hiring-contract_legende_item_label')
|
|
@@ -310,8 +304,7 @@ def datavisualisation_chiffres_cles_emplois(url):
|
|
| 310 |
for i in range(0,len(alltyperepartitions)):
|
| 311 |
allrepartitions += "<tr><td>" + removeTags(allrepartition[i]).replace('(' + removeTags(allpcrepartition[i]) + ')','') + "</td><td>" + removeTags(allpcrepartition[i]).replace('%','').replace(',','.') + "</td></tr>"
|
| 312 |
allrepartitions += "</table>"
|
| 313 |
-
|
| 314 |
-
|
| 315 |
allentrepriserepartitions = soup.select('div.horizontal-graph_pattern.sm-bubble_wrapper > span')
|
| 316 |
allentreprise = soup.select('span.sr-only')
|
| 317 |
allpcentreprise = soup.select('span.data.ng-star-inserted')
|
|
@@ -319,7 +312,6 @@ def datavisualisation_chiffres_cles_emplois(url):
|
|
| 319 |
for i in range(0,len(allentrepriserepartitions)):
|
| 320 |
allentreprises += "<tr><td>" + removeTags(allentrepriserepartitions[i])[0:-4] + "</td><td>" + removeTags(allentrepriserepartitions[i])[-4:].replace('%','').replace(',','.').strip() + "</td></tr>"
|
| 321 |
allentreprises += "</table>"
|
| 322 |
-
print("Entreprise : " + allentreprises)
|
| 323 |
|
| 324 |
return [alldemandeurs, allsalaires, alldifficultes, allrepartitions, allentreprises]
|
| 325 |
|
|
@@ -1279,21 +1271,21 @@ def update_tableau(selectedData, array_value, theme):
|
|
| 1279 |
|
| 1280 |
return create_tableau(df_FT, theme)
|
| 1281 |
|
| 1282 |
-
|
| 1283 |
-
|
| 1284 |
-
|
| 1285 |
-
|
| 1286 |
-
|
| 1287 |
-
|
| 1288 |
-
|
| 1289 |
-
|
| 1290 |
-
|
| 1291 |
-
|
| 1292 |
|
| 1293 |
@callback(
|
| 1294 |
Output("clicked-output", "children"),
|
| 1295 |
Output("clicked-output-tabs", "children"),
|
| 1296 |
-
|
| 1297 |
Input("loading-button", "n_clicks"),
|
| 1298 |
Input(component_id='framework-multi-select', component_property='value'),
|
| 1299 |
Input("mantine-provider", "forceColorScheme"),
|
|
@@ -1336,9 +1328,24 @@ def load_from_stats(n_clicks, array_value, theme):
|
|
| 1336 |
children_tabs = []
|
| 1337 |
for j in range(0, len(array_value)):
|
| 1338 |
table = datavisualisation_chiffres_cles_emplois("https://dataemploi.pole-emploi.fr/metier/chiffres-cles/NAT/FR/" + array_value[j])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1339 |
array_label_rome = searchByRome(array_value[j])
|
| 1340 |
df_demandeur = htmlToDataframe(table[0])
|
| 1341 |
df_demandeur = df_demandeur.sort_values(by=['Indicateur'])
|
|
|
|
| 1342 |
fig_demandeur = px.histogram(df_demandeur, x='Indicateur', y='Valeur', height=800, template=template, title="Demandeurs d'emploi et offres d'emploi du code ROME : " + array_label_rome[0]['label'], color='Indicateur', labels={'Valeur':'Nombre'}, text_auto=True).update_layout(font=dict(size=9),paper_bgcolor=paper_bgcolor,plot_bgcolor=plot_bgcolor,autosize=True)
|
| 1343 |
children.append(dmc.GridCol(html.Div(dcc.Loading(id="loadingPlot",children=(dcc.Graph(figure=fig_demandeur)),type="default")), span=6),)
|
| 1344 |
children_tabs.append(dmc.GridCol(html.Div(dcc.Loading(id="loadingPlot",children=[dbc.Label("Demandeurs d'emploi et offres d'emploi du code ROME : " + array_label_rome[0]['label']),dash_table.DataTable(data=df_demandeur.to_dict('records'),sort_action='native', columns=[{'id': c, 'name': c} for c in df_demandeur.columns],page_action='native', page_current= 0,page_size= 10,style_header=style_header,style_data=style_data,style_table={'overflowX': 'auto'},style_cell={'overflow': 'hidden','textOverflow': 'ellipsis','maxWidth': 0,})],type="default")), span=12),)
|
|
@@ -1368,7 +1375,7 @@ def load_from_stats(n_clicks, array_value, theme):
|
|
| 1368 |
children.append(dmc.GridCol(html.Div(dcc.Loading(id="loadingPlot",children=(dcc.Graph(figure=fig_repartitionEntreprise)),type="default")), span=6))
|
| 1369 |
children_tabs.append(dmc.GridCol(html.Div(dcc.Loading(id="loadingPlot",children=[dbc.Label("Répartition des embauches du métier : type entreprise du code ROME : " + array_label_rome[0]['label']),dash_table.DataTable(data=df_repartitionEntreprise.to_dict('records'),sort_action='native', columns=[{'id': c, 'name': c} for c in df_repartitionEntreprise.columns],page_action='native', page_current= 0,page_size= 10,style_header=style_header,style_data=style_data,style_table={'overflowX': 'auto'},style_cell={'overflow': 'hidden','textOverflow': 'ellipsis','maxWidth': 0,})],type="default")), span=12),)
|
| 1370 |
|
| 1371 |
-
return dmc.Grid(children=children), dmc.Grid(children=children_tabs)
|
| 1372 |
|
| 1373 |
#clientside_callback(
|
| 1374 |
# """
|
|
|
|
| 237 |
def datavisualisation_chiffres_cles_emplois(url):
|
| 238 |
response = requests.get(url)
|
| 239 |
soup = BeautifulSoup(response.text, "html.parser")
|
|
|
|
| 240 |
alldemandeurs = ''
|
| 241 |
allsalaires = ''
|
| 242 |
alldifficultes = ''
|
|
|
|
| 250 |
allnumembauches = allnumembauches.replace(" ","").strip()
|
| 251 |
else:
|
| 252 |
allnumembauches = removeTags(allnumembauchesfirst[0]).replace(" ","").strip()
|
|
|
|
| 253 |
if removeTags(allnumembauchesfirst[1]).find('\xa0') != -1:
|
| 254 |
allnumoffres = removeTags(allnumembauchesfirst[1]).split('\xa0')
|
| 255 |
allnumoffres = ''.join(allnumoffres)
|
| 256 |
allnumoffres = allnumoffres.replace(" ","").strip()
|
| 257 |
else:
|
| 258 |
allnumoffres = removeTags(allnumembauchesfirst[1]).replace(" ","").strip()
|
|
|
|
| 259 |
|
| 260 |
alldetailembauches = soup.select('p.hiring_text.ng-star-inserted')
|
| 261 |
allnumevolutionembauches = soup.select('p.main.ng-star-inserted')
|
|
|
|
| 273 |
alldemandeurs += "</td>"
|
| 274 |
alldemandeurs += "<td>" + allnumoffres + "</td></tr>"
|
| 275 |
alldemandeurs += "</table>"
|
|
|
|
| 276 |
|
| 277 |
allFAP = soup.select('tr.sectorTable__line.ng-star-inserted')
|
| 278 |
allcategorie = soup.select('td.sectorTable__cell')
|
|
|
|
| 288 |
allsalaires += "<tr><td>" + removeTags(alltypesalaires[2]) + "</td><td>" + removeTags(allcategorie[4]) + "</td><td>" + removeTags(allFAPsalaires[4]).replace('\xa0','').replace(' ','').replace('€','').replace(' ','').strip() + "</td></tr>"
|
| 289 |
allsalaires += "<tr><td>" + removeTags(alltypesalaires[3]) + "</td><td>" + removeTags(allcategorie[4]) + "</td><td>" + removeTags(allFAPsalaires[5]).replace('\xa0','').replace(' ','').replace('€','').replace(' ','').strip() + "</td></tr>"
|
| 290 |
allsalaires += "</table>"
|
|
|
|
| 291 |
|
| 292 |
alltypedifficultes = soup.select('.tabs-main-content_persp-col2-bar.ng-star-inserted')
|
| 293 |
alldifficulte = soup.select('p.horizontal-graph_title')
|
|
|
|
| 296 |
for i in range(0,len(alltypedifficultes)):
|
| 297 |
alldifficultes += "<tr><td>" + removeTags(alldifficulte[i]) + "</td><td>" + removeTags(allpcdifficulte[i]).replace('Pour le territoire principal FRANCE pour les ' + removeTags(alldifficulte[i]),'').replace('%','').strip() + "</td></tr>"
|
| 298 |
alldifficultes += "</table>"
|
|
|
|
| 299 |
|
| 300 |
alltyperepartitions = soup.select('div.hiring-contract_legende_item.ng-star-inserted')
|
| 301 |
allrepartition = soup.select('p.hiring-contract_legende_item_label')
|
|
|
|
| 304 |
for i in range(0,len(alltyperepartitions)):
|
| 305 |
allrepartitions += "<tr><td>" + removeTags(allrepartition[i]).replace('(' + removeTags(allpcrepartition[i]) + ')','') + "</td><td>" + removeTags(allpcrepartition[i]).replace('%','').replace(',','.') + "</td></tr>"
|
| 306 |
allrepartitions += "</table>"
|
| 307 |
+
|
|
|
|
| 308 |
allentrepriserepartitions = soup.select('div.horizontal-graph_pattern.sm-bubble_wrapper > span')
|
| 309 |
allentreprise = soup.select('span.sr-only')
|
| 310 |
allpcentreprise = soup.select('span.data.ng-star-inserted')
|
|
|
|
| 312 |
for i in range(0,len(allentrepriserepartitions)):
|
| 313 |
allentreprises += "<tr><td>" + removeTags(allentrepriserepartitions[i])[0:-4] + "</td><td>" + removeTags(allentrepriserepartitions[i])[-4:].replace('%','').replace(',','.').strip() + "</td></tr>"
|
| 314 |
allentreprises += "</table>"
|
|
|
|
| 315 |
|
| 316 |
return [alldemandeurs, allsalaires, alldifficultes, allrepartitions, allentreprises]
|
| 317 |
|
|
|
|
| 1271 |
|
| 1272 |
return create_tableau(df_FT, theme)
|
| 1273 |
|
| 1274 |
+
clientside_callback(
|
| 1275 |
+
"""
|
| 1276 |
+
function updateLoadingState(n_clicks) {
|
| 1277 |
+
return true
|
| 1278 |
+
}
|
| 1279 |
+
""",
|
| 1280 |
+
Output("loading-button", "loading", allow_duplicate=True),
|
| 1281 |
+
Input("loading-button", "n_clicks"),
|
| 1282 |
+
prevent_initial_call=True,
|
| 1283 |
+
)
|
| 1284 |
|
| 1285 |
@callback(
|
| 1286 |
Output("clicked-output", "children"),
|
| 1287 |
Output("clicked-output-tabs", "children"),
|
| 1288 |
+
Output("loading-button", "loading"),
|
| 1289 |
Input("loading-button", "n_clicks"),
|
| 1290 |
Input(component_id='framework-multi-select', component_property='value'),
|
| 1291 |
Input("mantine-provider", "forceColorScheme"),
|
|
|
|
| 1328 |
children_tabs = []
|
| 1329 |
for j in range(0, len(array_value)):
|
| 1330 |
table = datavisualisation_chiffres_cles_emplois("https://dataemploi.pole-emploi.fr/metier/chiffres-cles/NAT/FR/" + array_value[j])
|
| 1331 |
+
|
| 1332 |
+
response = requests.get("https://dataemploi.pole-emploi.fr/metier/chiffres-cles/NAT/FR/" + array_value[j])
|
| 1333 |
+
soup = BeautifulSoup(response.text, "html.parser")
|
| 1334 |
+
allembauches = soup.select('p.population_category')
|
| 1335 |
+
allnumembauchesfirst = soup.select('p.population_main-num.data')
|
| 1336 |
+
if removeTags(allnumembauchesfirst[0]).find('\xa0') != -1:
|
| 1337 |
+
allnumembauches = removeTags(allnumembauchesfirst[0]).split('\xa0')
|
| 1338 |
+
allnumembauches = ''.join(allnumembauches)
|
| 1339 |
+
allnumembauches = allnumembauches.replace(" ","").strip()
|
| 1340 |
+
else:
|
| 1341 |
+
allnumembauches = removeTags(allnumembauchesfirst[0]).replace(" ","").strip()
|
| 1342 |
+
|
| 1343 |
+
print("Le code HTML est : " + soup)
|
| 1344 |
+
print("Le nombre d'embauches : " + allnumembauches)
|
| 1345 |
array_label_rome = searchByRome(array_value[j])
|
| 1346 |
df_demandeur = htmlToDataframe(table[0])
|
| 1347 |
df_demandeur = df_demandeur.sort_values(by=['Indicateur'])
|
| 1348 |
+
print(df_demandeur)
|
| 1349 |
fig_demandeur = px.histogram(df_demandeur, x='Indicateur', y='Valeur', height=800, template=template, title="Demandeurs d'emploi et offres d'emploi du code ROME : " + array_label_rome[0]['label'], color='Indicateur', labels={'Valeur':'Nombre'}, text_auto=True).update_layout(font=dict(size=9),paper_bgcolor=paper_bgcolor,plot_bgcolor=plot_bgcolor,autosize=True)
|
| 1350 |
children.append(dmc.GridCol(html.Div(dcc.Loading(id="loadingPlot",children=(dcc.Graph(figure=fig_demandeur)),type="default")), span=6),)
|
| 1351 |
children_tabs.append(dmc.GridCol(html.Div(dcc.Loading(id="loadingPlot",children=[dbc.Label("Demandeurs d'emploi et offres d'emploi du code ROME : " + array_label_rome[0]['label']),dash_table.DataTable(data=df_demandeur.to_dict('records'),sort_action='native', columns=[{'id': c, 'name': c} for c in df_demandeur.columns],page_action='native', page_current= 0,page_size= 10,style_header=style_header,style_data=style_data,style_table={'overflowX': 'auto'},style_cell={'overflow': 'hidden','textOverflow': 'ellipsis','maxWidth': 0,})],type="default")), span=12),)
|
|
|
|
| 1375 |
children.append(dmc.GridCol(html.Div(dcc.Loading(id="loadingPlot",children=(dcc.Graph(figure=fig_repartitionEntreprise)),type="default")), span=6))
|
| 1376 |
children_tabs.append(dmc.GridCol(html.Div(dcc.Loading(id="loadingPlot",children=[dbc.Label("Répartition des embauches du métier : type entreprise du code ROME : " + array_label_rome[0]['label']),dash_table.DataTable(data=df_repartitionEntreprise.to_dict('records'),sort_action='native', columns=[{'id': c, 'name': c} for c in df_repartitionEntreprise.columns],page_action='native', page_current= 0,page_size= 10,style_header=style_header,style_data=style_data,style_table={'overflowX': 'auto'},style_cell={'overflow': 'hidden','textOverflow': 'ellipsis','maxWidth': 0,})],type="default")), span=12),)
|
| 1377 |
|
| 1378 |
+
return dmc.Grid(children=children), dmc.Grid(children=children_tabs), False
|
| 1379 |
|
| 1380 |
#clientside_callback(
|
| 1381 |
# """
|