在python中使用Selenium Web驱动程序检索可变文本的文本

时间:2018-12-07 19:25:25

标签: python selenium

我想检索以下文本:

var shotsData   = JSON.parse('\x7B\x22h\x22\x3A\x5B\x7B\x22id\x22\x3A\x2251764\x22,\x22minute\x22\x3A\x223\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.7709999847412109\x22,\x22Y\x22\x3A\x220.625999984741211\x22,\x22xG\x22\x3A\x220.01691202074289322\x22,\x22player\x22\x3A\x22Jordon\x20Ibe\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22481\x22,\x22situation\x22\x3A\x22FromCorner\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Martin\x20Skrtel\x22,\x22lastAction\x22\x3A\x22LayOff\x22\x7D,\x7B\x22id\x22\x3A\x2251766\x22,\x22minute\x22\x3A\x2223\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.754000015258789\x22,\x22Y\x22\x3A\x220.6140000152587891\x22,\x22xG\x22\x3A\x220.019624294713139534\x22,\x22player\x22\x3A\x22Christian\x20Benteke\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22606\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22BallRecovery\x22\x7D,\x7B\x22id\x22\x3A\x2251767\x22,\x22minute\x22\x3A\x2225\x22,\x22result\x22\x3A\x22Goal\x22,\x22X\x22\x3A\x220.9569999694824218\x22,\x22Y\x22\x3A\x220.4759999847412109\x22,\x22xG\x22\x3A\x220.5297861695289612\x22,\x22player\x22\x3A\x22Christian\x20Benteke\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22606\x22,\x22situation\x22\x3A\x22FromCorner\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Jordan\x20Henderson\x22,\x22lastAction\x22\x3A\x22Cross\x22\x7D,\x7B\x22id\x22\x3A\x2251768\x22,\x22minute\x22\x3A\x2228\x22,\x22result\x22\x3A\x22ShotOnPost\x22,\x22X\x22\x3A\x220.7930000305175782\x22,\x22Y\x22\x3A\x220.3820000076293945\x22,\x22xG\x22\x3A\x220.026856832206249237\x22,\x22player\x22\x3A\x22Jordan\x20Henderson\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22605\x22,\x22situation\x22\x3A\x22SetPiece\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22James\x20Milner\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251769\x22,\x22minute\x22\x3A\x2230\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.7809999847412109\x22,\x22Y\x22\x3A\x220.45099998474121095\x22,\x22xG\x22\x3A\x220.046132441610097885\x22,\x22player\x22\x3A\x22Philippe\x20Coutinho\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22488\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Christian\x20Benteke\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251770\x22,\x22minute\x22\x3A\x2243\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.7969999694824219\x22,\x22Y\x22\x3A\x220.30100000381469727\x22,\x22xG\x22\x3A\x220.0177763644605875\x22,\x22player\x22\x3A\x22Philippe\x20Coutinho\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22488\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Christian\x20Benteke\x22,\x22lastAction\x22\x3A\x22HeadPass\x22\x7D,\x7B\x22id\x22\x3A\x2251771\x22,\x22minute\x22\x3A\x2243\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.845\x22,\x22Y\x22\x3A\x220.47\x22,\x22xG\x22\x3A\x220.35637733340263367\x22,\x22player\x22\x3A\x22Philippe\x20Coutinho\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22488\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22None\x22\x7D,\x7B\x22id\x22\x3A\x2251775\x22,\x22minute\x22\x3A\x2250\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.825999984741211\x22,\x22Y\x22\x3A\x220.7169999694824218\x22,\x22xG\x22\x3A\x220.048670317977666855\x22,\x22player\x22\x3A\x22Jordon\x20Ibe\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22481\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Adam\x20Lallana\x22,\x22lastAction\x22\x3A\x22TakeOn\x22\x7D,\x7B\x22id\x22\x3A\x2251776\x22,\x22minute\x22\x3A\x2250\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.7709999847412109\x22,\x22Y\x22\x3A\x220.37599998474121094\x22,\x22xG\x22\x3A\x220.03337095305323601\x22,\x22player\x22\x3A\x22Philippe\x20Coutinho\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22488\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22Dispossessed\x22\x7D,\x7B\x22id\x22\x3A\x2251777\x22,\x22minute\x22\x3A\x2254\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.9269999694824219\x22,\x22Y\x22\x3A\x220.585\x22,\x22xG\x22\x3A\x220.13849252462387085\x22,\x22player\x22\x3A\x22James\x20Milner\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22489\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Jordon\x20Ibe\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251782\x22,\x22minute\x22\x3A\x2267\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.805\x22,\x22Y\x22\x3A\x220.24399999618530274\x22,\x22xG\x22\x3A\x220.05305565521121025\x22,\x22player\x22\x3A\x22Philippe\x20Coutinho\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22488\x22,\x22situation\x22\x3A\x22DirectFreekick\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22Standard\x22\x7D,\x7B\x22id\x22\x3A\x2251783\x22,\x22minute\x22\x3A\x2269\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.8669999694824219\x22,\x22Y\x22\x3A\x220.26799999237060546\x22,\x22xG\x22\x3A\x220.04357287660241127\x22,\x22player\x22\x3A\x22Philippe\x20Coutinho\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22488\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Christian\x20Benteke\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251784\x22,\x22minute\x22\x3A\x2271\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.8780000305175781\x22,\x22Y\x22\x3A\x220.5209999847412109\x22,\x22xG\x22\x3A\x220.11290974915027618\x22,\x22player\x22\x3A\x22Philippe\x20Coutinho\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22488\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22None\x22\x7D,\x7B\x22id\x22\x3A\x2251785\x22,\x22minute\x22\x3A\x2273\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.8490000152587891\x22,\x22Y\x22\x3A\x220.43400001525878906\x22,\x22xG\x22\x3A\x220.12811991572380066\x22,\x22player\x22\x3A\x22Philippe\x20Coutinho\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22488\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Christian\x20Benteke\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251791\x22,\x22minute\x22\x3A\x2287\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.7869999694824219\x22,\x22Y\x22\x3A\x220.295\x22,\x22xG\x22\x3A\x220.026128865778446198\x22,\x22player\x22\x3A\x22Nathaniel\x20Clyne\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22603\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22None\x22\x7D,\x7B\x22id\x22\x3A\x2251792\x22,\x22minute\x22\x3A\x2289\x22,\x22result\x22\x3A\x22SavedShot\x22,\x22X\x22\x3A\x220.9330000305175781\x22,\x22Y\x22\x3A\x220.48700000762939455\x22,\x22xG\x22\x3A\x220.4758010804653168\x22,\x22player\x22\x3A\x22Christian\x20Benteke\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22606\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Nathaniel\x20Clyne\x22,\x22lastAction\x22\x3A\x22Cross\x22\x7D,\x7B\x22id\x22\x3A\x2251793\x22,\x22minute\x22\x3A\x2289\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.865\x22,\x22Y\x22\x3A\x220.45099998474121095\x22,\x22xG\x22\x3A\x220.09445803612470627\x22,\x22player\x22\x3A\x22Adam\x20Lallana\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22486\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3Anull,\x22lastAction\x22\x3A\x22Rebound\x22\x7D,\x7B\x22id\x22\x3A\x2251794\x22,\x22minute\x22\x3A\x2291\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.7859999847412109\x22,\x22Y\x22\x3A\x220.5820000076293945\x22,\x22xG\x22\x3A\x220.027517924085259438\x22,\x22player\x22\x3A\x22James\x20Milner\x22,\x22h_a\x22\x3A\x22h\x22,\x22player_id\x22\x3A\x22489\x22,\x22situation\x22\x3A\x22SetPiece\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Emre\x20Can\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D\x5D,\x22a\x22\x3A\x5B\x7B\x22id\x22\x3A\x2251765\x22,\x22minute\x22\x3A\x2211\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.9219999694824219\x22,\x22Y\x22\x3A\x220.610999984741211\x22,\x22xG\x22\x3A\x220.028754938393831253\x22,\x22player\x22\x3A\x22Joshua\x20King\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22465\x22,\x22situation\x22\x3A\x22FromCorner\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22Head\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Max\x20Gradel\x22,\x22lastAction\x22\x3A\x22Cross\x22\x7D,\x7B\x22id\x22\x3A\x2251772\x22,\x22minute\x22\x3A\x2246\x22,\x22result\x22\x3A\x22SavedShot\x22,\x22X\x22\x3A\x220.7369999694824219\x22,\x22Y\x22\x3A\x220.549000015258789\x22,\x22xG\x22\x3A\x220.019499795511364937\x22,\x22player\x22\x3A\x22Matt\x20Ritchie\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22461\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Eunan\x20O\x26\x23039\x3BKane\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251773\x22,\x22minute\x22\x3A\x2248\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.830999984741211\x22,\x22Y\x22\x3A\x220.3129999923706055\x22,\x22xG\x22\x3A\x220.03587422892451286\x22,\x22player\x22\x3A\x22Matt\x20Ritchie\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22461\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Callum\x20Wilson\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251774\x22,\x22minute\x22\x3A\x2249\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.7980000305175782\x22,\x22Y\x22\x3A\x220.34\x22,\x22xG\x22\x3A\x220.02344721555709839\x22,\x22player\x22\x3A\x22Callum\x20Wilson\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22468\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Matt\x20Ritchie\x22,\x22lastAction\x22\x3A\x22Chipped\x22\x7D,\x7B\x22id\x22\x3A\x2251778\x22,\x22minute\x22\x3A\x2259\x22,\x22result\x22\x3A\x22ShotOnPost\x22,\x22X\x22\x3A\x220.8519999694824218\x22,\x22Y\x22\x3A\x220.3129999923706055\x22,\x22xG\x22\x3A\x220.044646721333265305\x22,\x22player\x22\x3A\x22Matt\x20Ritchie\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22461\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Joshua\x20King\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251779\x22,\x22minute\x22\x3A\x2262\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.785\x22,\x22Y\x22\x3A\x220.3890000152587891\x22,\x22xG\x22\x3A\x220.03107462450861931\x22,\x22player\x22\x3A\x22Matt\x20Ritchie\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22461\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22LeftFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Eunan\x20O\x26\x23039\x3BKane\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251780\x22,\x22minute\x22\x3A\x2262\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.9440000152587891\x22,\x22Y\x22\x3A\x220.33099998474121095\x22,\x22xG\x22\x3A\x220.07165629416704178\x22,\x22player\x22\x3A\x22Eunan\x20O\x26\x23039\x3BKane\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22472\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Callum\x20Wilson\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251781\x22,\x22minute\x22\x3A\x2264\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.7759999847412109\x22,\x22Y\x22\x3A\x220.42700000762939455\x22,\x22xG\x22\x3A\x220.03037465177476406\x22,\x22player\x22\x3A\x22Matt\x20Ritchie\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22461\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Max\x20Gradel\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251786\x22,\x22minute\x22\x3A\x2279\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.9159999847412109\x22,\x22Y\x22\x3A\x220.5970000076293945\x22,\x22xG\x22\x3A\x220.03618964925408363\x22,\x22player\x22\x3A\x22Steve\x20Cook\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22458\x22,\x22situation\x22\x3A\x22FromCorner\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22Head\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Max\x20Gradel\x22,\x22lastAction\x22\x3A\x22Cross\x22\x7D,\x7B\x22id\x22\x3A\x2251787\x22,\x22minute\x22\x3A\x2283\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.720999984741211\x22,\x22Y\x22\x3A\x220.500999984741211\x22,\x22xG\x22\x3A\x220.014533559791743755\x22,\x22player\x22\x3A\x22Eunan\x20O\x26\x23039\x3BKane\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22472\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Andrew\x20Surman\x22,\x22lastAction\x22\x3A\x22HeadPass\x22\x7D,\x7B\x22id\x22\x3A\x2251788\x22,\x22minute\x22\x3A\x2284\x22,\x22result\x22\x3A\x22BlockedShot\x22,\x22X\x22\x3A\x220.9059999847412109\x22,\x22Y\x22\x3A\x220.315\x22,\x22xG\x22\x3A\x220.056477561593055725\x22,\x22player\x22\x3A\x22Lee\x20Tomlin\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22975\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22RightFoot\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Adam\x20Smith\x22,\x22lastAction\x22\x3A\x22Pass\x22\x7D,\x7B\x22id\x22\x3A\x2251789\x22,\x22minute\x22\x3A\x2285\x22,\x22result\x22\x3A\x22MissedShots\x22,\x22X\x22\x3A\x220.915\x22,\x22Y\x22\x3A\x220.5\x22,\x22xG\x22\x3A\x220.04438130930066109\x22,\x22player\x22\x3A\x22Lee\x20Tomlin\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22975\x22,\x22situation\x22\x3A\x22FromCorner\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22OtherBodyPart\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Matt\x20Ritchie\x22,\x22lastAction\x22\x3A\x22Aerial\x22\x7D,\x7B\x22id\x22\x3A\x2251790\x22,\x22minute\x22\x3A\x2287\x22,\x22result\x22\x3A\x22SavedShot\x22,\x22X\x22\x3A\x220.9380000305175781\x22,\x22Y\x22\x3A\x220.36700000762939455\x22,\x22xG\x22\x3A\x220.023894228041172028\x22,\x22player\x22\x3A\x22Lee\x20Tomlin\x22,\x22h_a\x22\x3A\x22a\x22,\x22player_id\x22\x3A\x22975\x22,\x22situation\x22\x3A\x22OpenPlay\x22,\x22season\x22\x3A\x222015\x22,\x22shotType\x22\x3A\x22Head\x22,\x22match_id\x22\x3A\x22100\x22,\x22h_team\x22\x3A\x22Liverpool\x22,\x22a_team\x22\x3A\x22Bournemouth\x22,\x22h_goals\x22\x3A\x221\x22,\x22a_goals\x22\x3A\x220\x22,\x22date\x22\x3A\x222015\x2D08\x2D17\x2023\x3A00\x3A00\x22,\x22player_assisted\x22\x3A\x22Simon\x20Francis\x22,\x22lastAction\x22\x3A\x22Aerial\x22\x7D\x5D\x7D')
来自以下website

如果检查页面,我会发现以下xPath链接到所需的输出: / html / body / div / div 2 / div {{3} } / div 1 / div / script / text()

使用1的文档编写以下脚本:

from selenium import webdriver
import selenium.webdriver.support.expected_conditions as ec
import selenium.webdriver.support.ui as ui
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('https://understat.com/match/100')
shots = driver.find_element_by_xpath("//html/body/div/div[2]/div[1]/div[1]/div/script")

但是,输出为空。有人知道我在做什么错吗? 谢谢

1 个答案:

答案 0 :(得分:0)

您想得太多了,数据已经被解析了,所以:

shots = driver.execute_script("return shotsData")