datacipen commited on
Commit
b8606e8
·
verified ·
1 Parent(s): a47801d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -237,6 +237,7 @@ 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
  alldemandeurs = ''
241
  allsalaires = ''
242
  alldifficultes = ''
@@ -250,13 +251,15 @@ def datavisualisation_chiffres_cles_emplois(url):
250
  allnumembauches = allnumembauches.replace(" ","").strip()
251
  else:
252
  allnumembauches = removeTags(allnumembauchesfirst[0]).replace(" ","").strip()
253
-
254
  if removeTags(allnumembauchesfirst[1]).find('\xa0') != -1:
255
  allnumoffres = removeTags(allnumembauchesfirst[1]).split('\xa0')
256
  allnumoffres = ''.join(allnumoffres)
257
  allnumoffres = allnumoffres.replace(" ","").strip()
258
  else:
259
  allnumoffres = removeTags(allnumembauchesfirst[1]).replace(" ","").strip()
 
 
260
  alldetailembauches = soup.select('p.hiring_text.ng-star-inserted')
261
  allnumevolutionembauches = soup.select('p.main.ng-star-inserted')
262
  alldetailevolutionembauches = soup.select('p.population_bubble-title')
@@ -273,7 +276,8 @@ def datavisualisation_chiffres_cles_emplois(url):
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')
279
  alltypesalaires = soup.select('th.sectorTable__cell')
@@ -288,7 +292,8 @@ def datavisualisation_chiffres_cles_emplois(url):
288
  allsalaires += "<tr><td>" + removeTags(alltypesalaires[2]) + "</td><td>" + removeTags(allcategorie[4]) + "</td><td>" + removeTags(allFAPsalaires[4]).replace('\xa0','').replace(' ','').replace('€','').replace('&nbsp;','').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('&nbsp;','').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')
294
  allpcdifficulte = soup.select('div.horizontal-graph_data')
@@ -296,7 +301,8 @@ def datavisualisation_chiffres_cles_emplois(url):
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')
302
  allpcrepartition = soup.select('span.hiring-contract_legende_item-first')
@@ -304,6 +310,7 @@ def datavisualisation_chiffres_cles_emplois(url):
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')
@@ -312,7 +319,8 @@ def datavisualisation_chiffres_cles_emplois(url):
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
 
318
  def localisation():
@@ -793,7 +801,6 @@ def layout(**kwargs):
793
  dmc.Button("Afficher les statistiques des métiers", mt=10, ml="auto", id="loading-button", leftSection=DashIconify(icon="tabler:chart-pie")),
794
  html.Div(id="clicked-output"),
795
  html.Div(id="clicked-output-tabs"),
796
- html.Div(dmc.Text(id="html-output-tabs")),
797
  ], value="2"),
798
  dmc.TabsPanel(
799
  children=[
@@ -1287,7 +1294,6 @@ def update_tableau(selectedData, array_value, theme):
1287
  Output("clicked-output", "children"),
1288
  Output("clicked-output-tabs", "children"),
1289
  #Output("loading-button", "loading"),
1290
- Output("html-output-tabs", "children"),
1291
  Input("loading-button", "n_clicks"),
1292
  Input(component_id='framework-multi-select', component_property='value'),
1293
  Input("mantine-provider", "forceColorScheme"),
@@ -1362,8 +1368,7 @@ def load_from_stats(n_clicks, array_value, theme):
1362
  children.append(dmc.GridCol(html.Div(dcc.Loading(id="loadingPlot",children=(dcc.Graph(figure=fig_repartitionEntreprise)),type="default")), span=6))
1363
  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),)
1364
 
1365
- html_chiffres_cles = table[0] + table[1] + table[2] + table[3] + table[4]
1366
- return dmc.Grid(children=children), dmc.Grid(children=children_tabs), html_chiffres_cles
1367
 
1368
  #clientside_callback(
1369
  # """
 
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
  allnumembauches = allnumembauches.replace("&nbsp;","").strip()
252
  else:
253
  allnumembauches = removeTags(allnumembauchesfirst[0]).replace("&nbsp;","").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("&nbsp;","").strip()
259
  else:
260
  allnumoffres = removeTags(allnumembauchesfirst[1]).replace("&nbsp;","").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')
265
  alldetailevolutionembauches = soup.select('p.population_bubble-title')
 
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')
283
  alltypesalaires = soup.select('th.sectorTable__cell')
 
292
  allsalaires += "<tr><td>" + removeTags(alltypesalaires[2]) + "</td><td>" + removeTags(allcategorie[4]) + "</td><td>" + removeTags(allFAPsalaires[4]).replace('\xa0','').replace(' ','').replace('€','').replace('&nbsp;','').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('&nbsp;','').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')
299
  allpcdifficulte = soup.select('div.horizontal-graph_data')
 
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')
308
  allpcrepartition = soup.select('span.hiring-contract_legende_item-first')
 
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
+ print("Répartition : " + allrepartitions)
314
 
315
  allentrepriserepartitions = soup.select('div.horizontal-graph_pattern.sm-bubble_wrapper > span')
316
  allentreprise = soup.select('span.sr-only')
 
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
 
326
  def localisation():
 
801
  dmc.Button("Afficher les statistiques des métiers", mt=10, ml="auto", id="loading-button", leftSection=DashIconify(icon="tabler:chart-pie")),
802
  html.Div(id="clicked-output"),
803
  html.Div(id="clicked-output-tabs"),
 
804
  ], value="2"),
805
  dmc.TabsPanel(
806
  children=[
 
1294
  Output("clicked-output", "children"),
1295
  Output("clicked-output-tabs", "children"),
1296
  #Output("loading-button", "loading"),
 
1297
  Input("loading-button", "n_clicks"),
1298
  Input(component_id='framework-multi-select', component_property='value'),
1299
  Input("mantine-provider", "forceColorScheme"),
 
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
  # """