#python #html #parsing #beautifulsoup
#python #HTML #синтаксический анализ #beautifulsoup
Вопрос:
nameList = soup.find_all("span", {"class":"answer-number"})
for item in nameList:
print('item.content[0]')
Я написал приведенный выше код, но он не работает. Пожалуйста, помогите. Мне нужен номер 6а из него.
Ответ №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