2011-01-09 11 views
2

Ich brauche Inhalt einer HTML-Seiten, aber wenn eine HTML-Seite ein Iframe-Element enthält, brauche ich iframe Inhalt auch. (in Python) Ist es möglich, alles mit einer Python-Funktion zu laden?Get Iframe Inhalt in Python

+0

Bitte überprüfen @ Martijn Pieters Antwort auf diese Frage http://stackoverflow.com/questions/23028664/python-beautifulsoup-iframe-document-html-extract. Das kann dir helfen. –

Antwort

3

Versuchen Sie mit BeautifulSoup, die supports iframes out of the box.

-Code-Schnipsel (full code here):

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

UPDATE: den aktuellen Standort von Code verlinkte (jetzt in Github).

+0

util-Import funktioniert nicht auf meinem Computer. Warum? – barroco

+0

ignorieren Sie es, verwenden Sie einfach die BeautifulSoup Teile und passen sie an Ihre Bedürfnisse an. –

+0

der Link in "full code here" verweist auf http://www.zombievir.us/ – zeffii