Meta tag

HTML,CSS,JS

목록 보기
4/16

meta 태그?

<head></head> 부분에 들어가는, 눈으로 보이는 것(body) 외에 사이트의 속성을 설명해주는 태그들.

예) 구글 검색 시 표시 될 설명문, 사이트 제목, 카톡 공유 시 표시 될 이미지 등

→ 크롤링 시에 이용 → 기사 url만 입력했는데, 자동으로 불러와지는 부분들.

# meta tag 가져오는 법
og_image = soup.select_one('meta[property="og:image"]')
og_title = soup.select_one('meta[property="og:title"]')
og_description = soup.select_one('meta[property="og:description"]')

print(og_image)
print(og_title)
print(og_description)

# meta tag의 content 가져오는 법
url_image = og_image['content']
url_title = og_title['content']
url_description = og_description['content']

print(url_image)
print(url_title)
print(url_description)
profile
백엔드를 공부하고 있습니다.

0개의 댓글