Crawling through search keyword.
These days, Daum and Naver have changed from crawling to not being able to do it
I was going to do it with selenium
If you run the code below, you will get an empty value.
What's wrong?
from selenium import webdriver
import requests
from bs4 import BeautifulSoup
import time
dict_keyword = {}
def daum():
browser = webdriver.Chrome("C:/Users/eheee/Desktop/webdriver/chromedriver.exe")
browser.get("https://www.naver.com")
html = browser.page_source
soup = BeautifulSoup(driver.page_source, "html.parser")
search_word = soup.select("#sp_nws_all1 > dl > dt")
for i in search_word:
title = i.find("a").attrs['href']
link = "https://www.daum.net" + i.find("a")["href"]
dict_keyword[title.text] = title.get('href')
#return dict_keyword
print(dict_keyword)
Did you call daum()
?
Selenium is only imported, and it seems to crawl with beautiful soup
© 2024 OneMinuteCode. All rights reserved.