当我运行代码时:
import requests
from bs4 import BeautifulSoup
import urllib
response = urllib.urlopen('file:///Users/kerss/diet/sesame_seeds.html')
html = response.read()
soup = bs4.BeautifulSoup(html, 'html.parser')
span = soup.find("span", id="NUTRIENT_0")
print(span.text)
我收到以下错误:
File "c:\users\kerss\diet\scrape.py", line 8, in <module>
soup = bs4.BeautifulSoup(html, 'html.parser')
NameError: name 'bs4' is not defined
但是定义了bs4吗?还是不?
答案 0 :(得分:4)
只需使用{
"Id": "Policy98745183475249",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt15681834712546",
"Action": [
"s3:PutObject"
],
"Effect": "Allow",
"Resource": "arn:aws:s3:::buketname/*",
"Principal": {
"AWS": [
"arn:aws:iam::98754131531:user/Joe"
]
}
},{
"Sid": "Stmt15681834478323",
"Action": [
"s3:PutObject"
],
"Effect": "Deny",
"Resource": "arn:aws:s3:::buketname/*",
"Principal": "*"
},
]
}
答案 1 :(得分:2)
将from bs4 import BeautifulSoup
更改为import bs4