사이트 크롤링 도와주세요

사이트 크롤링 도와주세요

작성일 2024.01.27댓글 1건
    게시물 수정 , 삭제는 로그인 필요

https://m.sports.naver.com/kbaseball/schedule/index?date=2023-03-28

이 사이트에서 팀 이름이랑 경기 스코어 데이터를 크롤링하고 싶은데 코드 짜주실 수 있나요?
환경은 파이썬 bs4, selenium 으로 부탁드려요


#사이트 크롤링 #사이트 크롤링하기 #사이트 크롤링 파이썬 #사이트 크롤링 여부 확인 #사이트 크롤링 불법 #로그인 필요한 사이트 크롤링 #특정 사이트 크롤링 #php 사이트 크롤링 #주식 사이트 크롤링 #은행 사이트 크롤링

profile_image 익명 작성일 -

from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.service import Service from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from webdriver_manager.chrome import ChromeDriverManager # 설정 is_headless = False url = 'https://m.sports.naver.com/kbaseball/schedule/index?date=2023-03-28' options = Options() if is_headless: options.headless = True options.add_argument('--headless') options.add_experimental_option("detach", True) service = Service(executable_path=ChromeDriverManager().install()) driver = webdriver.Chrome(service=service, options=options) driver.maximize_window() wait = WebDriverWait(driver, 10) driver.get(url) iter_wait_el = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '#content > div > div:nth-child(4) > div > ul > li'))) iter_els = driver.find_elements(By.CSS_SELECTOR, '#content > div > div:nth-child(4) > div > ul > li') round_list = [] for el in iter_els: left_team_info_el = el.find_element(By.CSS_SELECTOR, 'div > div:nth-child(2) > div:nth-child(2) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > strong') left_team_score_el = el.find_element(By.CSS_SELECTOR, 'div > div:nth-child(2) > div:nth-child(2) > div:nth-child(2) > strong:nth-child(2)') right_team_info_el = el.find_element(By.CSS_SELECTOR, 'div > div:nth-child(2) > div:nth-child(3) > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > strong') right_team_score_el = el.find_element(By.CSS_SELECTOR, 'div > div:nth-child(2) > div:nth-child(3) > div:nth-child(2) > strong:nth-child(2)') left_team_name = '' left_team_score = '' right_team_name = '' right_team_score = '' if left_team_info_el: left_team_name = left_team_info_el.text.strip() if left_team_score_el: left_team_score = left_team_score_el.text.strip() if right_team_info_el: right_team_name = right_team_info_el.text.strip() if right_team_score_el: right_team_score = right_team_score_el.text.strip() round_list.append('{} {} vs {} {}'.format(left_team_name, left_team_score, right_team_name, right_team_score)) print(round_list)

도움이 되셨으면 좋겠습니다.

크롤링 셀레니움 도와주세요

... imgUrl = insta.select(".KL4Bh")[1].img['src'] # 오류 나시면 이렇게 해주세요 imgUrl = list(insta.select(".KL4Bh"))[1].img['src'] + 셀레니움으로 웹사이트크롤링하시는 건...

파이썬 크롤링도와주세요

... 해당 사이트는 BeautifulSoup + Request로 만드는데 문제가 없어보이지만 전체적으로 모든 사이트크롤링 하려면 Selenium같은게 좋습니다....

크롤링 질문입니다 도와주세요...

... 다른사이트 크롤링을 두번정도 만들어서 실행에도 성공을 했었는데요 네이버지도 크롤링을 하려니까 어떻게 시도해도 다 엘리먼트가 없다고 해서요 답변주시고...

파이선 크롤링 외계어 'cp949'

... 파이썬 크롤링 관련 문의드립니다. 파이썬 데이터... 도와주세요 오류가 아니라 텍스트 인코딩 문제입니다. 최근 웹 사이트들은 대부분 utf-8인데...



    test ad