barroco
barroco

Reputation: 3108

Get iframe content in python

I need content of a html pages, but if a html page contains a iframe element, I need iframe content too. (in Python) Is it possible to load everything with a python function?

Upvotes: 4

Views: 9373

Answers (1)

Adam Matan
Adam Matan

Reputation: 136141

Try using BeautifulSoup, which supports iframes out of the box.

Code snippet (full code here):

import re
from BeautifulSoup import BeautifulSoup, Comment
...
for iframe in mosoup("iframe"):
    mosoup.iframe.extract()

UPDATE: Linked to current location of code (now in github).

Upvotes: 3

Related Questions