from selenium import webdriver
from bs4 import BeautifulSoup
import sys
import time
driver = webdriver.Chrome("c:/Users/user/Documents/VScode/chromedriver.exe")
driver.implicitly_wait (3)
URL = "http://www.mediseminar.com"
time.sleep(5)
driver.get (URL)
soup = BeautifulSoup(driver.page_source, "html.parser")
result_monwebi = soup.select_one('#container > section.monWebiWrap > div.monWebi_wrap')
list_no = 0
for i in result_monwebi.find_all('li', attrs={'class':'swiper-slide slick-slide slick-current slick-active'}):
list_no += 1
semi_list = i.find('div', attrs={'class':'monWebi_txt'}).text
print("-----" + str(list_no) + "-----" + semi_list)
driver.close()
sys.exit()
I don't know why, but... I changed it to requests statement and analyzed it again, so it works well. Thank you all for your answers.
from bs4 import BeautifulSoup
import requests
import sys
URL = "http://www.mediseminar.com"
req = requests.get(URL)
#print(req.encoding) - Encoding analysis because Korean is broken
req.encoding='EUC-KR' #Encoding change
soup = BeautifulSoup(req.text, "html.parser")
result_monwebi = soup.select_one('#container > section.monWebiWrap > div.monWebi_wrap')
list_no = 0
for i in result_monwebi.find_all('li', attrs={'class':'swiper-slide'}):
list_no += 1
semi_list = i.find('div', attrs={'class':'monWebi_txt'}).text
print("-----" + str(list_no) + "-----" + semi_list)
sys.exit()
If the range of the object subject to the for statement is 0, the for statement does not work.
Compare the following examples.
a = []
for i in a:
print(1)
a = [6]
for i in a:
print(1)
606 Uncaught (inpromise) Error on Electron: An object could not be cloned
596 GDB gets version error when attempting to debug with the Presense SDK (IDE)
577 PHP ssh2_scp_send fails to send files as intended
884 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.