Guest User

Untitled

a guest
Feb 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. >>> import bs4
  2. >>> import requests
  3. >>> page = requests.get('http://www.betexplorer.com/soccer/scotland/premiership-2016-2017/results/').text
  4. >>> soup = bs4.BeautifulSoup(page, 'lxml')
  5. >>> ratio = soup.findAll('td', attrs={'class': 'h-text-center'})
  6. >>> ratio[0].findNextSiblings()
  7. [<td class="table-matches__odds colored"><span><span><span data-odd="1.16"></span></span></span></td>, <td class="table-matches__odds" data-odd="7.50"></td>, <td class="table-matches__odds" data-odd="14.67"></td>, <td class="h-text-right h-text-no-wrap">21.05.2017</td>]
  8. >>> len(ratio)
  9. 15
  10. >>> zeroth_ratio_sibs = ratio[0].findNextSiblings()
  11. >>> first_item = list(zeroth_ratio_sibs[0].descendants)[2].attrs['data-odd']
  12. >>> first_item
  13. '1.16'
  14. >>> second_item = zeroth_ratio_sibs[1].attrs['data-odd']
  15. >>> second_item
  16. '7.50'
  17. >>> third_item = zeroth_ratio_sibs[2].attrs['data-odd']
  18. >>> third_item
  19. '14.67'
Add Comment
Please, Sign In to add comment