Closed daeun084 closed 11 months ago
from selenium import webdriver
from selenium.webdriver.common.by import By
import requests
from bs4 import BeautifulSoup
from urllib.request import urlopen
#!pip install selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
url = "https://saint.ssu.ac.kr/irj/portal"
login_url = "https://smartid.ssu.ac.kr/Symtra_sso/smln.asp?apiReturnUrl=https%3A%2F%2Fsaint.ssu.ac.kr%2FwebSSO%2Fsso.jsp"
username = "20203058"
password = "λΉλ°λ²νΈ"
login_data = {
"userid": username,
"pwd": password
}
session = requests.Session()
driver = webdriver.Chrome()
driver.implicitly_wait(3)
driver.get(login_url)
# 'find_element_by_name' λμ 'find_element'μ By.NAMEμ μ¬μ©ν©λλ€.
username_element = driver.find_element(By.NAME, 'userid')
password_element = driver.find_element(By.NAME, 'pwd')
username_element.send_keys(username)
password_element.send_keys(password)
login_button = driver.find_element(By.XPATH, '//*[@id="sLogin"]/div/div[1]/form/div/div[2]/a')
login_button.click()
wait = WebDriverWait(driver, 10)
# μ΄μ HTML λ΄μ©μ κ°μ Έμ¬ μ μμ΅λλ€.
html = driver.page_source
soup = BeautifulSoup(html, "html.parser")
member_name = soup.find("span", {"class": "top_user"})
print(member_name)
#html = session.get(url)
#soup = BeautifulSoup(html.text, "html.parser")
#print(soup)
from selenium import webdriver
from selenium.webdriver.common.by import By
import requests
from bs4 import BeautifulSoup
from urllib.request import urlopen
#!pip install selenium
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
url = "https://saint.ssu.ac.kr/irj/portal"
login_url = "https://smartid.ssu.ac.kr/Symtra_sso/smln.asp?apiReturnUrl=https%3A%2F%2Fsaint.ssu.ac.kr%2FwebSSO%2Fsso.jsp"
username = "20203058"
password = "λΉλ°λ²νΈ"
login_data = {
"userid": username,
"pwd": password
}
session = requests.Session()
driver = webdriver.Chrome()
driver.implicitly_wait(3)
driver.get(login_url)
# 'find_element_by_name' λμ 'find_element'μ By.NAMEμ μ¬μ©ν©λλ€.
username_element = driver.find_element(By.NAME, 'userid')
password_element = driver.find_element(By.NAME, 'pwd')
username_element.send_keys(username)
password_element.send_keys(password)
login_button = driver.find_element(By.XPATH, '//*[@id="sLogin"]/div/div[1]/form/div/div[2]/a')
login_button.click()
// λ‘κ·ΈμΈν μνμμ νλ©΄ μ΄λ κ°λ₯
button = driver.find_element(By.XPATH, '//*[@id="ddba4fb5fbc996006194d3c0c0aea5c4"]/a')
button.click()
wait = WebDriverWait(driver, 30)
# μ΄μ HTML λ΄μ©μ κ°μ Έμ¬ μ μμ΅λλ€.
html = driver.page_source
soup = BeautifulSoup(html, "html.parser")
member_name = soup.find("μννΈ")
print(soup)
μ°¬λ―Όμ΄λ κ°μ λ°©μμΌλ‘ κ³μ μλλ₯Ό ν΄λ³΄κ³ μμλλ° μ΄λ° λ°©μμΌλ‘ μμ±νλκΉ μΈμ μ΄ λ§λ£λμ κ·Έλ°κ°? μλ λ‘κ·Έμμ λμ΄λ²λ €μ μνλ νμ΄μ§ μ½λλ₯Ό μ»μ μκ° μμ
#!pip install selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
import requests
import re
from bs4 import BeautifulSoup
from urllib.request import urlopen
from selenium.webdriver.support.ui import WebDriverWait
# μ μΈμΈνΈ ννμ΄μ§ μ£Όμμ λ‘κ·ΈμΈ νμ΄μ§ μ£Όμ
url = "https://saint.ssu.ac.kr/irj/portal"
login_url = "https://smartid.ssu.ac.kr/Symtra_sso/smln.asp?apiReturnUrl=https%3A%2F%2Fsaint.ssu.ac.kr%2FwebSSO%2Fsso.jsp"
# μ
λ ₯ λ°μ μμ΄λμ λΉλ°λ²νΈ
username = "20203058"
password = "Jjw112233#"
# requestsλ₯Ό ν΅ν΄ μΈμ
μμ
# session = requests.Session()
driver = webdriver.Chrome()
driver.implicitly_wait(3)
driver.get(login_url)
# 'find_element_by_name' λμ 'find_element'μ By.NAMEμ μ¬μ©ν©λλ€.
# νκ·Έ μμλ₯Ό μ°Ύμμ κ·Έ νκ·Έκ° κ°μΈκ³ μλ μμ΄λμ λΉλ² λ°μ΄ν°λ₯Ό 보λΈλ€
username_element = driver.find_element(By.NAME, 'userid')
password_element = driver.find_element(By.NAME, 'pwd')
username_element.send_keys(username)
password_element.send_keys(password)
login_button = driver.find_element(By.XPATH, '//*[@id="sLogin"]/div/div[1]/form/div/div[2]/a')
login_button.click()
# λ‘κ·ΈμΈν μνμμ νλ©΄ μ΄λ κ°λ₯
button = driver.find_element(By.XPATH, '//*[@id="ddba4fb5fbc996006194d3c0c0aea5c4"]/a')
button.click()
wait = WebDriverWait(driver, 30)
num_element = driver.find_element(By.CSS_SELECTOR, 'body > script:nth-child(13)')
number = num_element.get_attribute('innerHTML')
num_index = number.find(username);
print(number[num_index:num_index+8])
iframe_element = driver.find_element(By.NAME, 'contentAreaFrame')
driver.switch_to.frame(iframe_element)
iframe2_element = driver.find_element(By.XPATH, '//*[@id="isolatedWorkArea"]')
driver.switch_to.frame(iframe2_element)
wait = WebDriverWait(driver, 30)
class_element = driver.find_element(By.CSS_SELECTOR, '#WDFD')
print(class_element.get_attribute('value'))
driver.switch_to.default_content()
#!pip install selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
import requests
import re
from bs4 import BeautifulSoup
from urllib.request import urlopen
from selenium.webdriver.support.ui import WebDriverWait
# μ μΈμΈνΈ ννμ΄μ§ μ£Όμμ λ‘κ·ΈμΈ νμ΄μ§ μ£Όμ
url = "https://saint.ssu.ac.kr/irj/portal"
login_url = "https://smartid.ssu.ac.kr/Symtra_sso/smln.asp?apiReturnUrl=https%3A%2F%2Fsaint.ssu.ac.kr%2FwebSSO%2Fsso.jsp"
# μ
λ ₯ λ°μ μμ΄λμ λΉλ°λ²νΈ
username = "20192396"
password = "wjdtntkdtjs13@26"
# requestsλ₯Ό ν΅ν΄ μΈμ
μμ
# session = requests.Session()
driver = webdriver.Chrome()
driver.implicitly_wait(3)
driver.get(login_url)
# 'find_element_by_name' λμ 'find_element'μ By.NAMEμ μ¬μ©ν©λλ€.
# νκ·Έ μμλ₯Ό μ°Ύμμ κ·Έ νκ·Έκ° κ°μΈκ³ μλ μμ΄λμ λΉλ² λ°μ΄ν°λ₯Ό 보λΈλ€
username_element = driver.find_element(By.NAME, 'userid')
password_element = driver.find_element(By.NAME, 'pwd')
username_element.send_keys(username)
password_element.send_keys(password)
login_button = driver.find_element(By.XPATH, '//*[@id="sLogin"]/div/div[1]/form/div/div[2]/a')
login_button.click()
# λ‘κ·ΈμΈν μνμμ νλ©΄ μ΄λ κ°λ₯
button = driver.find_element(By.XPATH, '//*[@id="ddba4fb5fbc996006194d3c0c0aea5c4"]/a')
button.click()
wait = WebDriverWait(driver, 10)
num_element = driver.find_element(By.CSS_SELECTOR, 'body > script:nth-child(13)')
number = num_element.get_attribute('innerHTML')
num_index = number.find(username)
print(number[num_index:num_index+8])
iframe_element = driver.find_element(By.NAME, 'contentAreaFrame')
driver.switch_to.frame(iframe_element)
iframe2_element = driver.find_element(By.XPATH, '//*[@id="isolatedWorkArea"]')
driver.switch_to.frame(iframe2_element)
wait = WebDriverWait(driver, 10)
class_element = driver.find_element(By.CSS_SELECTOR, '#WDFD')
print(class_element.get_attribute('value'))
driver.switch_to.default_content()
grade_element = driver.find_element(By.XPATH, '//*[@id="8d3da4feb86b681d72f267880ae8cef5"]')
grade_element.click()
wait = WebDriverWait(driver, 10)
close_element = driver.find_element(By.XPATH, '//*[@id="30f2303171c98bdf57db799d0b834646"]/a')
close_element.click()
iframe_element = driver.find_element(By.NAME, 'contentAreaFrame')
driver.switch_to.frame(iframe_element)
iframe2_element = driver.find_element(By.XPATH, '//*[@id="isolatedWorkArea"]')
driver.switch_to.frame(iframe2_element)
wait = WebDriverWait(driver, 30)
# ν
μ΄λΈμ display-none λͺ©λ‘μ λͺ¨λ blockμΌλ‘ λ°κΎΈμ΄μ€
driver.execute_script('''
var tables = document.querySelectorAll('table');
tables.forEach(function(table) {
table.style.display = 'block';
});
''')
tables = driver.find_elements(By.XPATH, '/html/body/table')
# κ° ν
μ΄λΈμ λ΄μ© μΆλ ₯
time.sleep(3)
for table in tables:
# ν
μ΄λΈμ λͺ¨λ ν(row)μ μ°ΎκΈ°
rows = table.find_elements(By.TAG_NAME, 'tr')
# κ° νμ μ
(cell) μΆλ ₯
for row in rows:
cells = row.find_elements(By.TAG_NAME, 'td')
for cell in cells:
print(cell.text)
print("good")
π‘ Discription
π¨ Issue