Python BeautifulSoup4 Web Crawling Questions

Asked 1 years ago, Updated 1 years ago, 245 views

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)

python

2023-01-30 20:05

1 Answers

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.

This means to find all tags that have api_txt_lines classes and find all tags that have total_tit and _cross_trigger classes.


2023-01-30 20:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.