Home > Software design >  Python scraping - subtract class?
Python scraping - subtract class?

Time:10-10

I am new to python and programming and scraping. I would like to subtract one html tag from another: in "game_elements" there are all matches including lives, in "game_elements_live" there are only lives. In your opinion is it possible to only have non-live matches? I use requests and BeautifulSoup thank you so much

game_elements = html.select(".cardEvent.prebootFreeze.ng-star-inserted")
game_elements_live = html.select(".cardEvent.prebootFreeze.ng-star-inserted.is-live")   

CodePudding user response:

If you're using version 4.7.0 or later of Beautiful Soup, the select method should support the :not() selector, in which case game_elements = html.select(".cardEvent.prebootFreeze.ng-star-inserted:not(.is-live)") should work

CodePudding user response:

class_elements=".cardEvent.prebootFreeze.ng-star-inserted" game_elements_live = html.select(class_elements) for i in range(0,8): class_elements.pop() game_elements=html.select(class_elements)

  • Related