繁体   English   中英

抑制beautifulsoup中url的警告

[英]Suppress warning of url in beautifulsoup

我正在使用 Beautiful Soup 4 来解析一些从互联网上抓取的 html 格式的文本。 有时,此文本只是指向某个网站的链接。 BS4 非常交叉的一个事实是:

UserWarning: "http://example.com" looks like a URL. Beautiful Soup is not
an HTTP client. You should probably use an HTTP client to get the document
behind the URL, and feed that document to Beautiful Soup.

我很清楚这个事实,我只是想解释文本输入,而不是听课。 我使用控制台来监控脚本的活动,它被一个非常生气的库弄得乱七八糟。

有什么方法可以抑制或禁用此警告?

要简单地抑制警告并继续处理此工作:

import warnings
warnings.filterwarnings("ignore", category=UserWarning, module='bs4')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM