但是,使用时
print soup.article
它只会一直延伸到“ …艺术与Weise和fürverschiedene Zwecke 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
我怎样才能得到一切?
解决方法:
好的,终于找到了.欢迎来到刮刮的神奇世界.
在< 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('', '
')
soup = BeautifulSoup(source, "html.parser")
print soup.article
(我将< / br>替换为< br /> …)
这是一个很棒的刮板课程,这种东西很多,可以依靠:)
标签:beautifulsoup,web-scraping,python
来源: https://codeday.me/bug/20191025/1931855.html