我试图获取文章标记中的所有内容,让我们说http://magazine.magix.com/de/5-tipps-fuer-die-fotobearbeitung/
但是,使用时
print soup.article
它只会走到“... ... auf verschiedene Art und WeiseundfürverschiedeneZwecke bearbeiten。”
整个代码:
from bs4 import BeautifulSoup
import requests
request_page = requests.get('http://magazine.magix.com/de/5-tipps-fuer-die-fotobearbeitung/', 'html.parser')
source = request_page.text
soup = BeautifulSoup(source, "html.parser")
print soup.article.text
我怎样才能得到一切?
答案 0 :(得分:4)
好的,终于找到了。欢迎来到令人惊叹的刮刮世界。
在<article>
代码中,存在一些</br>
代码,该代表肯定意为<br/>
。
无论如何,它打破了html流程,因此BS努力解析它。
以下是我解决它的方法:
from bs4 import BeautifulSoup
import requests
request_page = requests.get('http://magazine.magix.com/de/5-tipps-fuer-die-fotobearbeitung/', 'html.parser')
source = request_page.text
source = source.replace('</br>', '<br/>')
soup = BeautifulSoup(source, "html.parser")
print soup.article
(我将</br>
替换为<br/>
...)
这是一个很好的刮痧,这种东西很多,依赖于:)