我刚刚在我的 Mac(High Sierra v 10.13.2)上安装了 Python 3.7。当我运行使用 sklearn 的代码时,我收到以下错误消息:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn/feature_extraction/text.py:17: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working from collections import Mapping, defaultdict
Run Code Online (Sandbox Code Playgroud)
有人知道如何消除这种弃用警告吗?我知道我可以要求 Python 不要显示弃用警告。我想删除弃用警告的原因,而不仅仅是删除警告本身。我想了解的是,我是否可以更改 SKLearn 对集合的使用,或者我是否需要等待 sklearn 完成?
我正在尝试使用 BeautifulSoup 从文章中提取图像 url 和图像标题。我可以将文章的图片 url 和图片标题与前后 HTML 分开,但我不知道如何将这两个与它们的 html 标签分开。这是我的代码:
from bs4 import BeautifulSoup
import requests
url = 'http://www.prnewswire.com/news-releases/dutch-philosopher-
koert-van-mensvoort-founder-of-the-next-nature-network-writes-a-
letter-to-humanity-619925063.html'
r = requests.get(url)
html = r.text
soup = BeautifulSoup(html, 'lxml')
links = soup.find_all('div', {'class': 'image'})
Run Code Online (Sandbox Code Playgroud)
我试图提取的两个部分是 src= 和 title= 部分。任何关于如何完成这两个解析的想法将不胜感激。