def parse_tags(tags: pq.PyQuery): 'Returns a dictionary with game_type, ranked, season' ret_dict = {} def read_tag(idx: int, tag_elem): tag = pq.PyQuery(tag_elem).text() if tag.find('Season') >= 0: try: ret_dict['season'] = int(tag.split(' ')[1]) except Exception as e: print('Error while parsing season from text: {}'.format(tag)) elif tag.lower().find('ranked') >= 0: try: ret_dict['game_type'] = tag.split(' ')[1] ret_dict['ranked'] = tag.find('Ranked') >= 0 except Exception as e: print( 'Error while parsing if ranked from text: {}'.format(tag)) elif VersusType.is_versus(tag): try: ret_dict['versus_type'] = VersusType.from_str(tag) except Exception as e: print('Error while parsing versus from text: {}'.format(tag)) tags.map(read_tag) return ret_dict
async def css(self, query): """""" py = PyQuery(self.body) py = py(query) return py.map(self.py_to_response)