nameList = soup.find_all("span", {"class":"answer-number"})
for item in nameList:
print('item.content[0]')
我写了上面的代码,但它没有用。请帮忙。我想要它的数字6a。
答案 0 :(得分:-1)
>>> soup.findAll('span',{'class':'badgecount'})
[<span class="badgecount">9</span>, <span class="badgecount">23</span>, <span class="badgecount">51</span>, <span class="badgecount">8</span>, <span class="badgecount">40</span>, <span class="badgecount">83</span>, <span class="badgecount">20</span>, <span class="badgecount">88</span>, <span class="badgecount">104</span>, <span class="badgecount">3</span>, <span class="badgecount">22</span>, <span class="badgecount">39</span>, <span class="badgecount">1</span>, <span class="badgecount">12</span>, <span class="badgecount">45</span>]
>>> spans=soup.findAll('span',{'class':'badgecount'})
>>> for span in spans:
print span.text
9
23
51
8
40
83
20
88
104
3
22
39
1
12
45