
import requests
from bs4 import BeautifulSoup
from pymongo import MongoClient
import certifi
ca = certifi.where();
client = MongoClient('mongodb+srv://test:sparta@cluster0.cjav74r.mongodb.net/Cluster0?retryWrites=true&w=majority', tlsCAFile=ca)
db = client.dbsparta
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}
data = requests.get('https://movie.naver.com/movie/sdb/rank/rmovie.naver?sel=pnt&date=20210829',headers=headers)
soup = BeautifulSoup(data.text, 'html.parser')
movies = soup.select('#old_contnet > table > tbody > tr')
for movie in movies:
a = movie.select_one('td.title > div > a')
if a is not None:
title = a.text
rank = movie.select_one('td:nth-child(1) > img')['alt']
star = movie.select_one('td.point').text
print(rank,title,star)
doc = {
'title': title,
'rank': rank,
'star': star
}
db.movies.insert_one(doc)



여러번 질문 후에
튜터님이 최종적으로 그냥 노션에 있는 코드 완성된걸로 보내주셨는데
이렇게 저도 이미 해보고 안되서 반복적으로 문의드린건데 좀 해결방식이 그러네요..
결국 오류가 해결되지 못했습니다.
다시 요청드립니다..
강좌 다른거 보고 있는데도
저 단계에서 막히니까
실제론 해보지 못하고 있습니다.
