I'm practicing web crawling to get the title of the View tab in the Naver search results, but the data is not imported as [] is displayed incorrectly.
For some reason, I'd like to ask the seniors for their opinions.
from bs4 import BeautifulSoup
import requests
base_url = "https://search.naver.com/search.naver?where=nexearch&sm=top_hty&fbm=1&ie=utf8&query="
keyword = input("Enter search term :")
search_url = base_url + keyword
r = requests.get(search_url)
soup = BeautifulSoup(r.text, "html.parser")
items = soup.select(".api_txt_lines total_tit._cross_trigger")
print(items)
The actual Naver search results page does not have a selection of the selector .api_txt_lines total_it._cross_trigger
.
If you access the Naver search results page with a browser and open the developer tool, you can find out the cause.
If you don't know what a selector is, see this document.
.api_txt_lines total_tit._cross_trigger
This means to find all tags that have api_txt_lines
classes and find all tags that have total_tit
and _cross_trigger
classes.
© 2024 OneMinuteCode. All rights reserved.