Pycharm 中未使用的导入语句 "import lxml"
Unused import statement "import lxml" in Pycharm
我的代码:
import requests
import bs4
import lxml
res = requests.get("https://en.wikipedia.org/wiki/Pacific_blue-eye")
page = res.text
soup = bs4.BeautifulSoup(page, "lxml")
我将如何初始化 lxml?我是 python 和网络抓取的新手,所以如果我做了一些愚蠢的事情,请原谅我。提前致谢。
不需要 lxml 只需使用 html.parser 即可,这是一个示例:
import requests
from bs4 import BeautifulSoup
req = requests.get("https://en.wikipedia.org/wiki/Pacific_blue-eye")
soup = BeautifulSoup(req.content, 'html.parser')
objs = soup.find_all('a', href=True)
for obj in objs:
print(obj['href'])
无论如何你应该安装 bs4 和 requests 模块。
有关详细信息,您需要阅读文档 beautifulsoup documentation,希望我能帮上一点忙
我的代码:
import requests
import bs4
import lxml
res = requests.get("https://en.wikipedia.org/wiki/Pacific_blue-eye")
page = res.text
soup = bs4.BeautifulSoup(page, "lxml")
我将如何初始化 lxml?我是 python 和网络抓取的新手,所以如果我做了一些愚蠢的事情,请原谅我。提前致谢。
不需要 lxml 只需使用 html.parser 即可,这是一个示例:
import requests
from bs4 import BeautifulSoup
req = requests.get("https://en.wikipedia.org/wiki/Pacific_blue-eye")
soup = BeautifulSoup(req.content, 'html.parser')
objs = soup.find_all('a', href=True)
for obj in objs:
print(obj['href'])
无论如何你应该安装 bs4 和 requests 模块。 有关详细信息,您需要阅读文档 beautifulsoup documentation,希望我能帮上一点忙