-
Notifications
You must be signed in to change notification settings - Fork 1
/
monmaster_scraping.py
75 lines (47 loc) · 1.7 KB
/
monmaster_scraping.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
import pandas as pd
from parametres import code_formation
from parametres import username
from parametres import password
cand = pd.read_csv("no_candidats.csv")
print(cand)
driver = webdriver.Safari()
driver.get("https://interne.candidature.monmaster.gouv.fr/formationscandidatables/"+code_formation+"/candidatures")
driver.implicitly_wait(10)
time.sleep(4)
# In[ ]:
elem = driver.find_element(By.ID,"username")
elem.clear()
elem.send_keys(username)
elem = driver.find_element(By.ID,"password")
elem.clear()
elem.send_keys(password)
elem.send_keys(Keys.RETURN)
# In[ ]:
time.sleep(4)
for index, row in cand.iterrows():
print("Telechargement candidat ",index," code ",row.no)
WebDriverWait(driver, timeout=20).until(EC.presence_of_element_located(
(By.CSS_SELECTOR,"[id^=page-candidatures-noCandidat-]")))
time.sleep(1)
elem = driver.find_element(By.CSS_SELECTOR,"[id^=page-candidatures-noCandidat-]")
elem.clear()
elem.send_keys(row.no)
elem.send_keys(Keys.RETURN)
WebDriverWait(driver, timeout=20).until(EC.element_to_be_clickable(
(By.XPATH,"//a[contains(text(), 'Télécharger la candidature')]")))
time.sleep(1)
elem = driver.find_element(By.XPATH,"//a[contains(text(), 'Télécharger la candidature')]")
elem.click()
#driver.execute_script('arguments[0].click()', elem)
time.sleep(8)
driver.back()
driver.back()