import requests
from bs4 import BeautifulSoup
url = 'https://movie.naver.com/movie/bi/mi/basic.nhn?code=171539'
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(url,headers=headers)
soup = BeautifulSoup(data.text, 'html.parser')
title = soup.select_one('meta[property="og:title"]')['content']
print(title)
soup.select_one('meta[property="og:title"]')
위와 같이 'meta[]'를 활용하여 meta 태그 안에 있는 og:title, og:image, og: description과 같은 내용들을 가져올 수 있다.
'Development' 카테고리의 다른 글
[AWS] EC2 시작하기(명령어, FileZilla, Robo 3T) (0) | 2022.01.02 |
---|---|
[JavaScript] 페이지 새로고침 (0) | 2022.01.01 |
[flask] 서버와 클라이언트의 GET, POST API 설계 (0) | 2021.12.31 |
[flask] 기본 구조 (0) | 2021.12.31 |
[pymongo] database에 저장, 찾기, 바꾸기, 지우기 기본 코드 (0) | 2021.12.30 |