因此,如果您愿意从http://www.cricbuzz.com/live-cricket-scores/16478/aus-vs-nz-1st-odi-new-zealand-tour-of-australia-2016 获取实时游戏信息,那么该网址并不是您想要继续请求的确切页面。
基本上如您所说,该页面是由 ajax 请求更新的,所以您想要跟踪特定的 ajax url,在这种情况下为 http://push.cricbuzz.com/match-push?id=16478,它是 JSON 就绪的对象,这有多好?
{
"settings": {
"refresh": 15000,
"timeout": 30000,
"pull_geo": [],
"force_refresh": false,
"video_geo": {
"country": ["US",
"CA"]
},
"video_enabled": false,
"mode": "push"
},
"id": "16478",
"series": {
"id": "2444",
"name": "New Zealand tour of Australia, 2016",
"short_name": "NZ tour of AUS",
"type": "",
"tour": false,
"start_date": "1480723200",
"end_date": "1481328000",
"category": "International"
},
"start_time": "1480821600",
"exp_end_time": "1480850400",
"state": "inprogress",
"dn": true,
"match_desc": "1st ODI",
"type": "ODI",
"live_coverage": true,
"minor_series": false,
"state_title": "Live",
"status": "New Zealand need 257 runs",
"score": {
"over_summary": {
"over": "5",
"ball_def": "30",
"rem_over": "5",
"runs": "33",
"wickets": "0",
"fours": "6",
"sixes": "0"
},
"prev_overs": " . 1 . . . . | 4 . 4 . . 4 | . . 1 1 . 4 | 4 . . 1 ",
"batting": {
"id": "13",
"score": "68/2 (13.4 Ovs)",
"innings": [{
"id": "2",
"score": "68",
"wkts": "2",
"overs": "13.4"
}]
},
"bowling": {
"id": "4",
"score": "324/8 (50.0 Ovs)",
"innings": [{
"id": "1",
"score": "324",
"wkts": "8",
"overs": "50"
}]
},
"rrr": "7.07",
"max_overs": "50",
"crr": "4.98",
"target": "325",
"prtshp": "34(35)",
"last_wkt": "6326",
"last_wkt_score": "9 (16)",
"batsman": [{
"id": "8983",
"strike": "1",
"r": "12",
"b": "15",
"4s": "2",
"6s": "0"
},
{
"id": "1457",
"strike": "0",
"r": "43",
"b": "45",
"4s": "5",
"6s": "2"
}],
"bowler": [{
"id": "8095",
"o": "1.4",
"m": "0",
"r": "17",
"w": "0"
},
{
"id": "6250",
"o": "3",
"m": "0",
"r": "12",
"w": "0"
}]
},
"hys": "false",
"toss": {
"winner": "Australia",
"decision": "Batting"
},
"team1": {
"id": "4",
"name": "Australia",
"s_name": "AUS",
"round_flag": "4_50.png",
"square_flag": "team_4_50.png",
"squad": [1739,
1643,
2250,
1440,
6250,
8497,
1649,
8095,
7710,
8642,
6258],
"squad_bench": [7662,
7789,
8876]
},
"team2": {
"id": "13",
"name": "New Zealand",
"s_name": "NZ",
"round_flag": "13_50.png",
"square_flag": "team_13_50.png",
"squad": [1457,
8216,
6326,
8983,
8085,
1459,
10100,
8081,
9067,
10692,
8117],
"squad_bench": [10694,
1057,
8676]
},
"comm_lines": [{
"timestamp": "1480840812865",
"i_id": "2",
"evt": "other",
"comm": "A short-leg is in place now.."
},
{
"timestamp": "1480840809865",
"i_id": "2",
"o_no": "13.4",
"b_no": "82",
"score": "68",
"wkts": "2",
"batsman": [{
"id": "1457",
"strike": "1",
"4s": "5",
"6s": "2",
"r": "43",
"b": "45"
}],
"bowler": [{
"id": "8095",
"o": "1",
"m": "0",
"r": "17",
"w": "0",
"n": "0",
"wd": "0"
}],
"evt": "other",
"comm": "P Cummins to Guptill, 1 run, Cummins has been way too short in this spell, Guptill rides the bounce and cuts it square past cover, a single to the man in the deep"
},
{
"timestamp": "1480840769121",
"i_id": "2",
"o_no": "13.3",
"b_no": "81",
"score": "67",
"wkts": "2",
"batsman": [{
"id": "1457",
"strike": "1",
"4s": "5",
"6s": "2",
"r": "42",
"b": "44"
}],
"bowler": [{
"id": "8095",
"o": "1",
"m": "0",
"r": "16",
"w": "0",
"n": "0",
"wd": "0"
}],
"evt": "other",
"comm": "P Cummins to Guptill, no run, short and wide from Cummins, Guptill hopped across on the ferocious cut, gets beaten on the top-edge"
},
{
"timestamp": "1480840731850",
"i_id": "2",
"o_no": "13.2",
"b_no": "80",
"score": "67",
"wkts": "2",
"batsman": [{
"id": "1457",
"strike": "1",
"4s": "5",
"6s": "2",
"r": "42",
"b": "43"
}],
"bowler": [{
"id": "8095",
"o": "1",
"m": "0",
"r": "16",
"w": "0",
"n": "0",
"wd": "0"
}],
"evt": "other",
"comm": "P Cummins to Guptill, no run, Cummins responds with a bouncer, Guptill drops his wrists and lets it go"
},
{
"timestamp": "1480840699390",
"i_id": "2",
"o_no": "13.1",
"b_no": "79",
"score": "67",
"wkts": "2",
"batsman": [{
"id": "1457",
"strike": "1",
"4s": "5",
"6s": "2",
"r": "42",
"b": "42"
}],
"bowler": [{
"id": "8095",
"o": "1",
"m": "0",
"r": "16",
"w": "0",
"n": "0",
"wd": "0"
}],
"evt": "four",
"all_evt": ["four"],
"comm": "P Cummins to Guptill, <b>FOUR<\/b>, Cummins is leaking boundaries, this was full and wide of off. Guptill reaches out and slices the drive - square on the off-side, beats the fielder getting across from deep cover"
}],
"latest_video": {
"timestamp": "1480839773003",
"comm": "Hazlewood to Neesham, <b>FOUR<\/b>, nicely played by Neesham, full and on Neesham's pads, he gets inside the line and clips it past mid-wicket, the timing is sweet and the ball rolls away to the fence",
"comm": "Hazlewood to Neesham, <b>FOUR<\/b>, nicely played by Neesham, full and on Neesham's pads, he gets inside the line and clips it past mid-wicket, the timing is sweet and the ball rolls away to the fence",
"o_no": "9.4",
"video": "0_qbtvgqc4"
}
}
现在只需使用json 模块来解析它并提取你想要的任何东西。