code
import requests
from bs4 import BeautifulSoup
import json
url = 'https://ridibooks.com/category/bestsellers/6050'
req_header_dict = {
# 요청헤더 : 브라우저정보
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36'
}
res = requests.get(url, headers=req_header_dict)
html = res.text
soup = BeautifulSoup(html, 'html.parser')
next_data = soup.select('#__NEXT_DATA__')
book_list = []
for i in next_data:
a = i.text
book_list.append(json.loads(a))
with open('ridi.json', 'w', encoding='utf-8') as file:
json.dump(book_list, file, ensure_ascii=False, indent="\t")