怎么把这个汤做出来而不让它什么都不做?

2024-04-20 10:20:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我在修改BS4和web抓取,当我处理它时,变量变为空白

<!-- example.html -->

<html><head><title>The Website Title</title></head>
<body>
<p>Download my <strong>Python</strong> book from <a href="http://
inventwithpython.com">my website</a>.</p>
<p class="slogan">Learn Python the easy way!</p>
<p>By <span id="author">Al Sweigart</span></p>
</body></html>
import bs4
example = open('example.html')
soup = bs4.BeautifulSoup(example.read())
print(soup) # returns '[]'

Tags: thewebtitleexamplemyhtmlbodywebsite