擅长:python、mysql、java
<p>欢迎来到SO</p>
<p>如前面的回答所述,错误与使用错误的属性<code>.txt</code>有关,尽管<code>.text</code>正确</p>
<p>最后要注意的是,您试图刮取的页面加载了javascript,因此<code>requests</code>不是您要寻找的包。有关使用<code>selenium</code>webdriver的大致解决方案,请参见下文</p>
<pre><code>from selenium import webdriver
from bs4 import BeautifulSoup
driver = webdriver.Firefox() # initialize the driver
driver.get('https://www.steamstatus.io/') # go to the page
source = driver.page_source # extract the source
SteamPage = BeautifulSoup(source, 'html.parser')
SteamStatus = SteamPage.findAll('div', {'class' : 'statusrow'})
for s in SteamStatus:
print(s.findNext('div', {'class' : 'statusrow_name'}).text) # print the row name
print(s.findNext('div', {'class' : 'statusrow_status'}).text) # and the uploaded value
</code></pre>