728x90
imdb에서 클라이언트 변경 후 크롤링
https://www.imdb.com/chart/top/
IMDb Top 250 Movies
As rated by regular IMDb voters.
www.imdb.com
01. Network를 클리어한 후 URI에 접속후 「Network >headers」 에서 User-Agent를 확인

import requests
from bs4 import BeautifulSoup
url = "https://www.imdb.com/chart/top/"
headers = {"user-agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36",
"accept-language" : "en"}
res = requests.get(url, headers = headers)
res
<Response [200]>
res.text
soup.select("div.cli-children h3.ipc-title__text")
[<h3 class="ipc-title__text">1. The Shawshank Redemption</h3>,
<h3 class="ipc-title__text">2. The Godfather</h3>,
<h3 class="ipc-title__text">3. The Dark Knight</h3>,
<h3 class="ipc-title__text">4. The Godfather Part II</h3>,
<h3 class="ipc-title__text">5. 12 Angry Men</h3>,
<h3 class="ipc-title__text">6. The Lord of the Rings: The Return of the King</h3>,
<h3 class="ipc-title__text">7. Schindler's List</h3>,
<h3 class="ipc-title__text">8. Pulp Fiction</h3>,
<h3 class="ipc-title__text">9. The Lord of the Rings: The Fellowship of the Ring</h3>,
<h3 class="ipc-title__text">10. The Good, the Bad and the Ugly</h3>,
<h3 class="ipc-title__text">11. Forrest Gump</h3>,
<h3 class="ipc-title__text">12. The Lord of the Rings: The Two Towers</h3>,
<h3 class="ipc-title__text">13. Fight Club</h3>,
<h3 class="ipc-title__text">14. Inception</h3>,
<h3 class="ipc-title__text">15. Star Wars: Episode V - The Empire Strikes Back</h3>,
<h3 class="ipc-title__text">16. The Matrix</h3>,
<h3 class="ipc-title__text">17. Goodfellas</h3>,
<h3 class="ipc-title__text">18. One Flew Over the Cuckoo's Nest</h3>,
<h3 class="ipc-title__text">19. Interstellar</h3>,
<h3 class="ipc-title__text">20. Se7en</h3>,
<h3 class="ipc-title__text">21. It's a Wonderful Life</h3>,
<h3 class="ipc-title__text">22. Seven Samurai</h3>,
<h3 class="ipc-title__text">23. The Silence of the Lambs</h3>,
<h3 class="ipc-title__text">24. Saving Private Ryan</h3>,
<h3 class="ipc-title__text">25. City of God</h3>]728x90
'01_Python' 카테고리의 다른 글
| 56_파이썬(Python) API 사용법_공공 데이터 포털 (0) | 2025.03.11 |
|---|---|
| 55_파이썬(Python) API 사용법_네이버 블로그 (3) | 2025.03.11 |
| 54_파이썬(Python) API 사용법_영화진흥위원회 (1) | 2025.03.11 |
| 53_동적 크롤링 (2) | 2025.01.16 |
| 52_셀레니움(selenium)설치 (0) | 2025.01.16 |