[python] DBPIA 크롤링

go easy on NG·2023년 1월 2일
0

토이 프로젝트

목록 보기
5/8
from selenium import webdriver
from selenium.webdriver.common.by import By

import os
path=os.getcwd()+"/chromedriver"
browser=webdriver.Chrome(path)
search_name=input("검색어 : ")

url="https://www.dbpia.co.kr/search/topSearch?searchOption=all&query={}".format(search_name)
# print(url)
browser.get(url)
items = browser.find_elements(By.CLASS_NAME,'thesis__link')
# checkbox = browser.find_elements(By.CLASS_NAME, ' thesis__label')
checks = browser.find_elements(By.NAME,'checked-node')


for check in checks :
    if check.get_attribute('class') == "disabled thesis__check" :
        continue
    else:
        for item in items:
            a=item.get_attribute('href')
            browser.get(a)
            b=browser.find_element(By.CLASS_NAME,'thesisDetail__abstract').text.split("\n")
            print(b[2])
            print("-"*20)
            browser.back()
profile
🐥개발자

0개의 댓글