I understand that to get the contents of an iframe with beautifulsoup, you have to make a request for the src of the iframe.
However, when I do this, there is a div inside the iframe which I cannot seem to access.
res = requests.get('[iframe src]')
soup = bs4.BeautifulSoup(res.text, "html.parser")
print(soup)
This gives:
<!DOCTYPE html>
<html><head>...</head>
<body>
<div id="widgetApp"></div>
<script type="text/javascript"><script>
<script type="text/javascript"><script>
<script type="text/javascript"><script>
<script type="text/javascript"><script>
</body>
</html>
Using the developer tools/inspect element in browser, I can see that the #widgetApp div has plenty of other divs etc inside it. How do I get access to these?
Edit: To clarify, I'm trying to get access to the div #foo which is contained inside #widgetApp.
When I do:
elems = soup.select('#foo')
print(len(elems))
I get 0, ie it's not picking up the #foo div inside #widgetApp.
Hope that makes sense.
Any help very much appreciated.