I'm trying to get some information from https://wefut.com/player-database/22. In particular, the nation of the players. I've been using Selenium to get the rest of the information and it worked fine. However, I couldn't find a way to access the country, an example:
<a href="/nation/54/23" title="" rel="tooltip" data-original-title="Brazil">
I tried something like (driver.find_element(By.XPATH, xpath_country)).get_attribute('data-original-title')
But that just returns None. I couldn't find any useful information about this. Is there a way to do this, using Selenium or any other library? If not, I'm open to suggestions on other ways to obtain the information (maybe easily).
Thanks!
CodePudding user response:
Actually, there's no need to use Selenium
for this case. If you inspect your browsers Network calls (Click on F12) you'll see that the data is loaded dynamicallly via sending a POST
request to:
https://wefut.com/ajax/getPlayers/22
So, to get the data, you can use this example, you can acess the data with their keys
/values
as a normal dict
.
Note, I'm not sure if the cookies
you need to get the dynamically or not. If so, you can use a tools such as curlconverter.com
import requests
cookies = {
"wf_csrf_c": "98ca71d90e465992b20ed99bb6f48863",
"wf_sc": "ZENmE3GNNzYhW5MFyUUs2DUgdnTWjaSTeT5gxrukYIXWclPvLdUtqZ7RmKU8UWje/yz4hvcoEnXQw5HlhuYH/L6a3RzD+nWf4+9oCza3eVgTR7fRIzD6oY+Vb27h1Yti7p1pwh4lOk/+rOrLD3ZXvoEoCw9APyV23hKcYE8EAXeCPYjPCwwnN8S8ZSuJVmcRsTbfir/PTu9okyWD11iEyWkd5nNU5rV65Qlcn/qKVKFECEnvLa/dzkgkfGOmLwNCtasEoba6hVROw8PNwzNvUilBbLNrVmkfbk3f4ZmxpXkDS1eEfrbyp+sriZMKk+lrOd2//CRqY8W/1Vuv0ibMZ2fnsdBq39pUMVhqCjZO8AFHVt9u7tT9EBCSj7Ded/fcdq4gugjpPQZY1wTa4Tw3YdDl+iBHHkoDA6FWY3ZA82QIPnnnAl8WZAH8y/b+eV+Wx5Cojm4w30DebGAo7xnwBg==",
"_ga": "GA1.2.577503996.1672430468",
"_gid": "GA1.2.1097143011.1672430468",
"_gat_gtag_UA_39374027_1": "1",
}
data = {
"sEcho": "1",
"iColumns": "75",
"sColumns": "",
"iDisplayStart": "0",
"iDisplayLength": "25",
"mDataProp_0": "0",
"mDataProp_1": "1",
"mDataProp_2": "2",
"mDataProp_3": "3",
"mDataProp_4": "4",
"mDataProp_5": "5",
"mDataProp_6": "6",
"mDataProp_7": "7",
"mDataProp_8": "8",
"mDataProp_9": "9",
"mDataProp_10": "10",
"mDataProp_11": "11",
"mDataProp_12": "12",
"mDataProp_13": "13",
"mDataProp_14": "14",
"mDataProp_15": "15",
"mDataProp_16": "16",
"mDataProp_17": "17",
"mDataProp_18": "18",
"mDataProp_19": "19",
"mDataProp_20": "20",
"mDataProp_21": "21",
"mDataProp_22": "22",
"mDataProp_23": "23",
"mDataProp_24": "24",
"mDataProp_25": "25",
"mDataProp_26": "26",
"mDataProp_27": "27",
"mDataProp_28": "28",
"mDataProp_29": "29",
"mDataProp_30": "30",
"mDataProp_31": "31",
"mDataProp_32": "32",
"mDataProp_33": "33",
"mDataProp_34": "34",
"mDataProp_35": "35",
"mDataProp_36": "36",
"mDataProp_37": "37",
"mDataProp_38": "38",
"mDataProp_39": "39",
"mDataProp_40": "40",
"mDataProp_41": "41",
"mDataProp_42": "42",
"mDataProp_43": "43",
"mDataProp_44": "44",
"mDataProp_45": "45",
"mDataProp_46": "46",
"mDataProp_47": "47",
"mDataProp_48": "48",
"mDataProp_49": "49",
"mDataProp_50": "50",
"mDataProp_51": "51",
"mDataProp_52": "52",
"mDataProp_53": "53",
"mDataProp_54": "54",
"mDataProp_55": "55",
"mDataProp_56": "56",
"mDataProp_57": "57",
"mDataProp_58": "58",
"mDataProp_59": "59",
"mDataProp_60": "60",
"mDataProp_61": "61",
"mDataProp_62": "62",
"mDataProp_63": "63",
"mDataProp_64": "64",
"mDataProp_65": "65",
"mDataProp_66": "66",
"mDataProp_67": "67",
"mDataProp_68": "68",
"mDataProp_69": "69",
"mDataProp_70": "70",
"mDataProp_71": "71",
"mDataProp_72": "72",
"mDataProp_73": "73",
"mDataProp_74": "74",
"sSearch": "",
"bRegex": "false",
"sSearch_0": "",
"bRegex_0": "false",
"bSearchable_0": "true",
"sSearch_1": "",
"bRegex_1": "false",
"bSearchable_1": "true",
"sSearch_2": "",
"bRegex_2": "false",
"bSearchable_2": "true",
"sSearch_3": "",
"bRegex_3": "false",
"bSearchable_3": "true",
"sSearch_4": "",
"bRegex_4": "false",
"bSearchable_4": "true",
"sSearch_5": "",
"bRegex_5": "false",
"bSearchable_5": "true",
"sSearch_6": "",
"bRegex_6": "false",
"bSearchable_6": "true",
"sSearch_7": "",
"bRegex_7": "false",
"bSearchable_7": "true",
"sSearch_8": "",
"bRegex_8": "false",
"bSearchable_8": "true",
"sSearch_9": "",
"bRegex_9": "false",
"bSearchable_9": "true",
"sSearch_10": "",
"bRegex_10": "false",
"bSearchable_10": "true",
"sSearch_11": "",
"bRegex_11": "false",
"bSearchable_11": "true",
"sSearch_12": "",
"bRegex_12": "false",
"bSearchable_12": "true",
"sSearch_13": "",
"bRegex_13": "false",
"bSearchable_13": "true",
"sSearch_14": "",
"bRegex_14": "false",
"bSearchable_14": "true",
"sSearch_15": "",
"bRegex_15": "false",
"bSearchable_15": "true",
"sSearch_16": "",
"bRegex_16": "false",
"bSearchable_16": "true",
"sSearch_17": "",
"bRegex_17": "false",
"bSearchable_17": "true",
"sSearch_18": "",
"bRegex_18": "false",
"bSearchable_18": "true",
"sSearch_19": "",
"bRegex_19": "false",
"bSearchable_19": "true",
"sSearch_20": "",
"bRegex_20": "false",
"bSearchable_20": "true",
"sSearch_21": "",
"bRegex_21": "false",
"bSearchable_21": "true",
"sSearch_22": "",
"bRegex_22": "false",
"bSearchable_22": "true",
"sSearch_23": "",
"bRegex_23": "false",
"bSearchable_23": "true",
"sSearch_24": "",
"bRegex_24": "false",
"bSearchable_24": "true",
"sSearch_25": "",
"bRegex_25": "false",
"bSearchable_25": "true",
"sSearch_26": "",
"bRegex_26": "false",
"bSearchable_26": "true",
"sSearch_27": "",
"bRegex_27": "false",
"bSearchable_27": "true",
"sSearch_28": "",
"bRegex_28": "false",
"bSearchable_28": "true",
"sSearch_29": "",
"bRegex_29": "false",
"bSearchable_29": "true",
"sSearch_30": "",
"bRegex_30": "false",
"bSearchable_30": "true",
"sSearch_31": "",
"bRegex_31": "false",
"bSearchable_31": "true",
"sSearch_32": "",
"bRegex_32": "false",
"bSearchable_32": "true",
"sSearch_33": "",
"bRegex_33": "false",
"bSearchable_33": "true",
"sSearch_34": "",
"bRegex_34": "false",
"bSearchable_34": "true",
"sSearch_35": "",
"bRegex_35": "false",
"bSearchable_35": "true",
"sSearch_36": "",
"bRegex_36": "false",
"bSearchable_36": "true",
"sSearch_37": "",
"bRegex_37": "false",
"bSearchable_37": "true",
"sSearch_38": "",
"bRegex_38": "false",
"bSearchable_38": "true",
"sSearch_39": "",
"bRegex_39": "false",
"bSearchable_39": "true",
"sSearch_40": "",
"bRegex_40": "false",
"bSearchable_40": "true",
"sSearch_41": "",
"bRegex_41": "false",
"bSearchable_41": "true",
"sSearch_42": "",
"bRegex_42": "false",
"bSearchable_42": "true",
"sSearch_43": "",
"bRegex_43": "false",
"bSearchable_43": "true",
"sSearch_44": "",
"bRegex_44": "false",
"bSearchable_44": "true",
"sSearch_45": "",
"bRegex_45": "false",
"bSearchable_45": "true",
"sSearch_46": "",
"bRegex_46": "false",
"bSearchable_46": "true",
"sSearch_47": "",
"bRegex_47": "false",
"bSearchable_47": "true",
"sSearch_48": "",
"bRegex_48": "false",
"bSearchable_48": "true",
"sSearch_49": "",
"bRegex_49": "false",
"bSearchable_49": "true",
"sSearch_50": "",
"bRegex_50": "false",
"bSearchable_50": "true",
"sSearch_51": "",
"bRegex_51": "false",
"bSearchable_51": "true",
"sSearch_52": "",
"bRegex_52": "false",
"bSearchable_52": "true",
"sSearch_53": "",
"bRegex_53": "false",
"bSearchable_53": "true",
"sSearch_54": "",
"bRegex_54": "false",
"bSearchable_54": "true",
"sSearch_55": "",
"bRegex_55": "false",
"bSearchable_55": "true",
"sSearch_56": "",
"bRegex_56": "false",
"bSearchable_56": "true",
"sSearch_57": "",
"bRegex_57": "false",
"bSearchable_57": "true",
"sSearch_58": "",
"bRegex_58": "false",
"bSearchable_58": "true",
"sSearch_59": "",
"bRegex_59": "false",
"bSearchable_59": "true",
"sSearch_60": "",
"bRegex_60": "false",
"bSearchable_60": "true",
"sSearch_61": "",
"bRegex_61": "false",
"bSearchable_61": "true",
"sSearch_62": "",
"bRegex_62": "false",
"bSearchable_62": "true",
"sSearch_63": "",
"bRegex_63": "false",
"bSearchable_63": "true",
"sSearch_64": "",
"bRegex_64": "false",
"bSearchable_64": "true",
"sSearch_65": "",
"bRegex_65": "false",
"bSearchable_65": "true",
"sSearch_66": "",
"bRegex_66": "false",
"bSearchable_66": "true",
"sSearch_67": "",
"bRegex_67": "false",
"bSearchable_67": "true",
"sSearch_68": "",
"bRegex_68": "false",
"bSearchable_68": "true",
"sSearch_69": "",
"bRegex_69": "false",
"bSearchable_69": "true",
"sSearch_70": "",
"bRegex_70": "false",
"bSearchable_70": "true",
"sSearch_71": "",
"bRegex_71": "false",
"bSearchable_71": "true",
"sSearch_72": "",
"bRegex_72": "false",
"bSearchable_72": "true",
"sSearch_73": "",
"bRegex_73": "false",
"bSearchable_73": "true",
"sSearch_74": "",
"bRegex_74": "false",
"bSearchable_74": "true",
"iSortCol_0": "4",
"sSortDir_0": "desc",
"iSortingCols": "1",
"bSortable_0": "false",
"bSortable_1": "true",
"bSortable_2": "true",
"bSortable_3": "true",
"bSortable_4": "true",
"bSortable_5": "true",
"bSortable_6": "true",
"bSortable_7": "true",
"bSortable_8": "false",
"bSortable_9": "true",
"bSortable_10": "true",
"bSortable_11": "true",
"bSortable_12": "true",
"bSortable_13": "true",
"bSortable_14": "true",
"bSortable_15": "true",
"bSortable_16": "true",
"bSortable_17": "true",
"bSortable_18": "true",
"bSortable_19": "true",
"bSortable_20": "true",
"bSortable_21": "true",
"bSortable_22": "true",
"bSortable_23": "true",
"bSortable_24": "true",
"bSortable_25": "true",
"bSortable_26": "true",
"bSortable_27": "true",
"bSortable_28": "true",
"bSortable_29": "true",
"bSortable_30": "true",
"bSortable_31": "true",
"bSortable_32": "true",
"bSortable_33": "true",
"bSortable_34": "true",
"bSortable_35": "true",
"bSortable_36": "true",
"bSortable_37": "true",
"bSortable_38": "true",
"bSortable_39": "true",
"bSortable_40": "true",
"bSortable_41": "true",
"bSortable_42": "true",
"bSortable_43": "true",
"bSortable_44": "true",
"bSortable_45": "true",
"bSortable_46": "true",
"bSortable_47": "true",
"bSortable_48": "true",
"bSortable_49": "true",
"bSortable_50": "true",
"bSortable_51": "true",
"bSortable_52": "true",
"bSortable_53": "true",
"bSortable_54": "true",
"bSortable_55": "true",
"bSortable_56": "true",
"bSortable_57": "true",
"bSortable_58": "true",
"bSortable_59": "true",
"bSortable_60": "true",
"bSortable_61": "true",
"bSortable_62": "true",
"bSortable_63": "true",
"bSortable_64": "true",
"bSortable_65": "true",
"bSortable_66": "true",
"bSortable_67": "true",
"bSortable_68": "true",
"bSortable_69": "true",
"bSortable_70": "true",
"bSortable_71": "true",
"bSortable_72": "true",
"bSortable_73": "false",
"bSortable_74": "true",
"min_rating": "40",
"max_rating": "99",
"min_pace_tot": "",
"max_pace_tot": "",
"min_shooting_tot": "",
"max_shooting_tot": "",
"min_passing_tot": "",
"max_passing_tot": "",
"min_dribbling_tot": "",
"max_dribbling_tot": "",
"min_defending_tot": "",
"max_defending_tot": "",
"min_heading_tot": "",
"max_heading_tot": "",
"min_acceleration": "",
"max_acceleration": "",
"min_agility": "",
"max_agility": "",
"min_balance": "",
"max_balance": "",
"min_jumping": "",
"max_jumping": "",
"min_reactions": "",
"max_reactions": "",
"min_sprintspeed": "",
"max_sprintspeed": "",
"min_stamina": "",
"max_stamina": "",
"min_strength": "",
"max_strength": "",
"min_aggression": "",
"max_aggression": "",
"min_tact_aware": "",
"max_tact_aware": "",
"min_positioning": "",
"max_positioning": "",
"min_vision": "",
"max_vision": "",
"min_composure": "",
"max_composure": "",
"min_potential": "",
"max_potential": "",
"min_ball_control": "",
"max_ball_control": "",
"min_crossing": "",
"max_crossing": "",
"min_curve": "",
"max_curve": "",
"min_dribbling": "",
"max_dribbling": "",
"min_finishing": "",
"max_finishing": "",
"min_fk_acc": "",
"max_fk_acc": "",
"min_heading_acc": "",
"max_heading_acc": "",
"min_longpass": "",
"max_longpass": "",
"min_longshot": "",
"max_longshot": "",
"min_marking": "",
"max_marking": "",
"min_penalties": "",
"max_penalties": "",
"min_shortpass": "",
"max_shortpass": "",
"min_shotpower": "",
"max_shotpower": "",
"min_sliding_tackle": "",
"max_sliding_tackle": "",
"min_standing_tackle": "",
"max_standing_tackle": "",
"min_volleys": "",
"max_volleys": "",
"min_gk_diving": "",
"max_gk_diving": "",
"min_gk_handling": "",
"max_gk_handling": "",
"min_gk_kicking": "",
"max_gk_kicking": "",
"min_gk_reflexes": "",
"max_gk_reflexes": "",
"min_gk_speed": "",
"max_gk_speed": "",
"min_gk_positioning": "",
"max_gk_positioning": "",
"min_height": "",
"max_height": "",
"min_weight": "",
"max_weight": "",
"awr": "[]",
"dwr": "[]",
"skillmoves": "[]",
"weakfoot": "[]",
"preferredfoot": "[]",
"console": "2",
"type": "player",
"clubs": "[]",
"nations": "[]",
"positions": "[]",
"traits": "[]",
"minprice": "0",
"maxprice": "0",
"cardtype": "[]",
"min_dob": "",
"max_dob": "",
"totw": "",
"wf_csrf": "98ca71d90e465992b20ed99bb6f48863",
}
response = requests.post(
"https://wefut.com/ajax/getPlayers/22", cookies=cookies, data=data
).json()
for data in response["aaData"]:
print(data)
Prints (truncated):
{'0': '', '1': 'Mohamed', '2': 'Salah', '3': '', '4': '99', '5': '1992-06-15', '6': '175', '7': '0', '8': 'CAM', '9': 'Left', '10': 'Liverpool', '11': 'Premier League', '12': 'Egypt', '13': '99', '14': '99', '15': '96', '16': '99', '17': '54', '18': '88', '19': '98', '20': '99', '21': '99', '22': '82', '23': '99', '24': '99', '25': '99', '26': '88', '27': '77', '28': '66', '29': '99', '30': '98', '31': '0', '32': '98', '33': '96', '34': '99', '35': '99', '36': '99', '37': '85', '38': '70', '39': '92', '40': '98', '41': '46', '42': '99', '43': '98', '44': '98', '45': '48', '46': '52', '47': '99', '48': '0', '49': '0', '50': '0', '51': '0', '52': '0', '53': '0', '54': '5', '55': '5', '56': '<label >H</label>', '57': '<label >M</label>', '58': '23557/22', '59': '174', '60': '0', '61': None, '62': '0', '63': '9', '64': '13', '65': '111', '66': '209331', '67': '99', '68': 0, '69': 0, '70': 'Salah', '71': 'gold174', '72': 'pink', '73': 'pink', '74': '<button type="button" onclick="dbtosquad(23557, \'\', \'Salah\', 174, 22, [\'CAM\'])" rel="tooltip" title="Add to builder"><i ></i></button>', 'player_card': '<div data-base-id="209331" data-club-id="9" data-nation-id="111" data-league-id="13" data-rareflag="174">\r\n <div style="position: relative; z-index: 2">\r\n <img src="//static.wefut.com/assets/images/fut22/gold174.png?205" alt="" >\r\n\r\n <div ></div>\r\n\r\n <a href="https://wefut.com/club/9">\r\n <img src="//static.wefut.com/assets/images/fut22/clubbadges/9.png?21" alt="" >\r\n </a>\r\n \r\n <div >\r\n <img src="//static.wefut.com/assets/images/fut22/playeravatars/209331.png?21" one rror="this.src=\'//static.wefut.com/assets/images/fut15/playeravatars/unknown.png\'" alt="" >\r\n </div>\r\n\r\n <a href="https://wefut.com/nation/111">\r\n <img src="//static.wefut.com/assets/images/nation_flag/111.jpg" >\r\n </a>\r\n \r\n <div ><span style="border: 0px !important" >99</span></div>\r\n <span >CAM</span>\r\n <div >\r\n <span >Salah</span>\r\n </div>\r\n <div >\r\n <span >\r\n </span>\r\n \r\n \r\n <span >99</span>\r\n <span >99</span>\r\n <span >96</span>\r\n <span >99</span>\r\n <span >54</span>\r\n <span >88</span>\r\n </div>\r\n <div ></div>\r\n </div>\r\n </div>\r\n', 'player_url': 'player/22/23557/mohamed-salah'}
{'0': '', '1': 'Ousmane', '2': 'Dembélé', '3': '', '4': '99', '5': '1997-05-15', '6': '178', '7': '0', '8': 'RW', '9': 'Left', '10': 'FC Barcelona', '11': 'LaLiga Santander', '12': 'France', '13': '99', '14': '96', '15': '94', '16': '99', '17': '49', '18': '79', '19': '99', '20': '99', '21': '97', '22': '81', '23': '95', '24': '99', '25': '96', '26': '72', '27': '75', '28': '49', '29': '97', '30': '93', '31': '0', '32': '99', '33': '96', '34': '99', '35': '99', '36': '95', '37': '80', '38': '58', '39': '93', '40': '97', '41': '57', '42': '94', '43': '95', '44': '99', '45': '44', '46': '41', '47': '94', '48': '0', '49': '0', '50': '0', '51': '0', '52': '0', '53': '0', '54': '5', '55': '5', '56': '<label >H</label>', '57': '<label >M</label>', '58': '22456/22', '59': '174', '60': '0', '61': None, '62': '0', '63': '241', '64': '53', '65': '18', '66': '231443', '67': '96', '68': 0, '69': 0, '70': 'Dembélé', '71': 'gold174', '72': 'pink', '73': 'pink', '74': '<button type="button" onclick="dbtosquad(22456, \'\', \'Dembélé\', 174, 22, [\'RW\'])" rel="tooltip" title="Add to builder"><i ></i></button>', 'player_card': '<div data-base-id="231443" data-club-id="241" data-nation-id="18" data-league-id="53" data-rareflag="174">\r\n <div style="position: relative; z-index: 2">\r\n <img src="//static.wefut.com/assets/images/fut22/gold174.png?205" alt="" >\r\n\r\n <div ></div>\r\n\r\n <a href="https://wefut.com/club/241">\r\n <img src="//static.wefut.com/assets/images/fut22/clubbadges/241.png?21" alt="" >\r\n </a>\r\n \r\n <div >\r\n <img src="//static.wefut.com/assets/images/fut22/playeravatars/231443.png?21" one rror="this.src=\'//static.wefut.com/assets/images/fut15/playeravatars/unknown.png\'" alt="" >\r\n </div>\r\n\r\n <a href="https://wefut.com/nation/18">\r\n <img src="//static.wefut.com/assets/images/nation_flag/18.jpg" >\r\n </a>\r\n \r\n <div ><span style="border: 0px !important" >99</span></div>\r\n <span >RW</span>\r\n <div >\r\n <span >Dembélé</span>\r\n </div>\r\n <div >\r\n <span >\r\n </span>\r\n \r\n \r\n <span >99</span>\r\n <span >96</span>\r\n <span >94</span>\r\n <span >99</span>\r\n <span >49</span>\r\n <span >79</span>\r\n </div>\r\n <div ></div>\r\n </div>\r\n </div>\r\n', 'player_url': 'player/22/22456/ousmane-dembele'}
{'0': '', '1': 'Raphaël', '2': 'Varane', '3': '', '4': '99', '5': '1993-04-25', '6': '191', '7': '0', '8': 'CB', '9': 'Right', '10': 'Manchester United', '11': 'Premier League', '12': 'France', '13': '96', '14': '61', '15': '80', '16': '83', '17': '99', '18': '98', '19': '95', '20': '80', '21': '60', '22': '98', '23': '99', '24': '96', '25': '95', '26': '99', '27': '97', '28': '99', '29': '69', '30': '80', '31': '0', '32': '93', '33': '50', '34': '56', '35': '76', '36': '57', '37': '63', '38': '98', '39': '94', '40': '66', '41': '98', '42': '53', '43': '96', '44': '65', '45': '98', '46': '99', '47': '52', '48': '0', '49': '0', '50': '0', '51': '0', '52': '0', '53': '0', '54': '3', '55': '2', '56': '<label >M</label>', '57': '<label >H</label>', '58': '22450/22', '59': '174', '60': '0', '61': None, '62': '0', '63': '11', '64': '13', '65': '18', '66': '201535', '67': '97', '68': 0, '69': 0, '70': 'Varane', '71': 'gold174', '72': 'pink', '73': 'pink', '74': '<button type="button" onclick="dbtosquad(22450, \'\', \'Varane\', 174, 22, [\'CB\'])" rel="tooltip" title="Add to builder"><i ></i></button>', 'player_card': '<div data-base-id="201535" data-club-id="11" data-nation-id="18" data-league-id="13" data-rareflag="174">\r\n <div style="position: relative; z-index: 2">\r\n <img src="//static.wefut.com/assets/images/fut22/gold174.png?205" alt="" >\r\n\r\n <div ></div>\r\n\r\n <a href="https://wefut.com/club/11">\r\n <img src="//static.wefut.com/assets/images/fut22/clubbadges/11.png?21" alt="" >\r\n </a>\r\n \r\n <div >\r\n <img src="//static.wefut.com/assets/images/fut22/playeravatars/201535.png?21" one rror="this.src=\'//static.wefut.com/assets/images/fut15/playeravatars/unknown.png\'" alt="" >\r\n </div>\r\n\r\n <a href="https://wefut.com/nation/18">\r\n <img src="//static.wefut.com/assets/images/nation_flag/18.jpg" >\r\n </a>\r\n \r\n <div ><span style="border: 0px !important" >99</span></div>\r\n <span >CB</span>\r\n <div >\r\n <span >Varane</span>\r\n </div>\r\n <div >\r\n <span >\r\n </span>\r\n \r\n \r\n <span >96</span>\r\n <span >61</span>\r\n <span >80</span>\r\n <span >83</span>\r\n <span >99</span>\r\n <span >98</span>\r\n </div>\r\n <div ></div>\r\n </div>\r\n </div>\r\n', 'player_url': 'player/22/22450/raphael-varane'}
{'0': '', '1': 'C. Ronaldo', '2': 'dos Santos Aveiro', '3': 'Cristiano Ronaldo', '4': '99', '5': '1985-02-05', '6': '187', '7': '0', '8': 'LW', '9': 'Right', '10': 'Manchester United', '11': 'Premier League', '12': 'Portugal', '13': '99', '14': '99', '15': '90', '16': '97', '17': '50', '18': '92', '19': '99', '20': '97', '21': '90', '22': '99', '23': '99', '24': '99', '25': '95', '26': '95', '27': '81', '28': '47', '29': '99', '30': '91', '31': '0', '32': '98', '33': '94', '34': '93', '35': '97', '36': '99', '37': '91', '38': '99', '39': '85', '40': '99', '41': '38', '42': '93', '43': '90', '44': '99', '45': '39', '46': '50', '47': '95', '48': '0', '49': '0', '50': '0', '51': '0', '52': '0', '53': '0', '54': '4', '55': '5', '56': '<label >H</label>', '57': '<label >L</label>', '58': '22188/22', '59': '97', '60': '0', '61': None, '62': '0', '63': '11', '64': '13', '65': '38', '66': '20801', '67': '99', '68': 0, '69': 0, '70': 'Cristiano Ronaldo', '71': 'gold97', '72': 'shapeshifters', '73': 'shapeshifters', '74': '<button type="button" onclick="dbtosquad(22188, \'\', \'Cristiano Ronaldo\', 97, 22, [\'LW\'])" rel="tooltip" title="Add to builder"><i ></i></button>', 'player_card': '<div data-base-id="20801" data-club-id="11" data-nation-id="38" data-league-id="13" data-rareflag="97">\r\n <div style="position: relative; z-index: 2">\r\n <img src="//static.wefut.com/assets/images/fut22/gold97.png?205" alt="" >\r\n\r\n <div ></div>\r\n\r\n <a href="https://wefut.com/club/11">\r\n <img src="//static.wefut.com/assets/images/fut22/clubbadges/11.png?21" alt="" >\r\n </a>\r\n \r\n <div >\r\n <img src="//static.wefut.com/assets/images/fut22/playeravatars/20801.png?21" one rror="this.src=\'//static.wefut.com/assets/images/fut15/playeravatars/unknown.png\'" alt="" >\r\n </div>\r\n\r\n <a href="https://wefut.com/nation/38">\r\n <img src="//static.wefut.com/assets/images/nation_flag/38.jpg" >\r\n </a>\r\n \r\n <div ><span style="border: 0px !important" >99</span></div>\r\n <span >LW</span>\r\n <div >\r\n <span >Cristiano Ronaldo</span>\r\n </div>\r\n <div >\r\n <span >\r\n </span>\r\n \r\n \r\n <span >99</span>\r\n <span >99</span>\r\n <span >90</span>\r\n <span >97</span>\r\n <span >50</span>\r\n <span >92</span>\r\n </div>\r\n <div ></div>\r\n </div>\r\n </div>\r\n', 'player_url': 'player/22/22188/cristiano-ronaldo'}
CodePudding user response:
driver.get('https://httpbin.org')
qw = driver.find_element(By.CSS_SELECTOR,'body > a')
po = qw.get_attribute('aria-label')
this works... so there's probably some issue with your code
try adding a delay before finding element, or use this method
edit: after inspecting the site, countries are in 'title' attributes and 'data-original-title' doesnt exist on the page for me