Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> import bs4
- >>> import requests
- >>> page = requests.get('http://www.betexplorer.com/soccer/scotland/premiership-2016-2017/results/').text
- >>> soup = bs4.BeautifulSoup(page, 'lxml')
- >>> ratio = soup.findAll('td', attrs={'class': 'h-text-center'})
- >>> ratio[0].findNextSiblings()
- [<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>]
- >>> len(ratio)
- 15
- >>> zeroth_ratio_sibs = ratio[0].findNextSiblings()
- >>> first_item = list(zeroth_ratio_sibs[0].descendants)[2].attrs['data-odd']
- >>> first_item
- '1.16'
- >>> second_item = zeroth_ratio_sibs[1].attrs['data-odd']
- >>> second_item
- '7.50'
- >>> third_item = zeroth_ratio_sibs[2].attrs['data-odd']
- >>> third_item
- '14.67'
Add Comment
Please, Sign In to add comment