[scraping] iframe 가져오기

alirz-pixel·2022년 7월 21일
0

scraping

목록 보기
1/1

iframe의 URL 사용

만약, iframe의 url이 http://www.hellow.com 이라면

import requests
from bs4 import BeautifulSoup

url = "http://www.hellow.com"
response = requests.get(url=url).text
soup = BeautifulSoup(response)

로 해당 사이트의 iframe 내부를 스크래핑할 수 있다.

URL이 존재하지 않을 경우

iframe의 URL이 없을 경우, 아래의 명령어를 통해 url을 알아낼 수 있다.
document.getElementById('ID_selector').contentWindow.location.href

document.getElementById('hello').contentWindow.location.href
'http://www.hellow.com'

0개의 댓글