我不明白JSON在此网站上的运作方式

我有2个问题:

  1. 我的目标是从此示例网站(或其他直播篮球比赛)中抓取实时数据:

https://www.oddsportal.com/basketball/greece/greek-cup/promitheas-panathinaikos-MTkEXywD/inplay-odds/#over-under;1

当我打开开发工具并根据请求浏览JSON时:

https://fb.oddsportal.com/feed/live/1-3-zVIgebsh-2-1-yjc50.dat?_=1573397634508

我看到了更多数据,但我不知道该怎么做。 例如在上一页:

https://www.oddsportal.com/inplay-odds/live-now/basketball/

我有类似的表格,但是我设法得到了结果:

2.24-1.58-Filippos Veroi-AS Karditsas

1.26-3.56-拜仁-阿尔巴·柏林

1.24-4.21-拜罗伊特-不伦瑞克篮球

2.2-1.75-哥廷根-奥尔登堡

1.01-12.43-Donar Groningen-鹿特丹

通过此代码:

import json
import time
import pprint
import re
import sys

import requests
from bs4 import BeautifulSoup

url = "https://fb.oddsportal.com/feed/livegames/live/3/0.dat?_{}".format(int(time.time() * 1000))
headers = {
'User-Agent': 'curl/7.64.0','Referer': 'https://www.oddsportal.com/inplay-odds/live-now/basketball/',}
 page = requests.get(url,headers=headers)

 result = re.search("globals.jsonpCallback\('/feed/livegames/live/3/0.dat',(.*)\);",page.text)
 if not result:
   sys.exit("Result not found")   

 #print(result.group(1))
 json_text = result.group(1)
 json_data = json.loads(json_text).get('d')

 soup = BeautifulSoup(json_data.get('text',''),'html.parser')

 with open('test.html','w+') as f:
   f.write(str(soup))

for m in soup.select('tr[xeid]'):
name = m.find('td',class_='name table-participant').text
#print (len(name))
#ids = m.find_all('td',class_='live odds-nowrp')
xoid,xodd = (s['xoid'].split('-')[-1] for s in m.find_all('td',class_='live odds-nowrp'))
xoid_data = json_data.get('odds',{}).get(xoid)
xodd_data = json_data.get('odds',{}).get(xodd)
if xoid_data is not None:
    xoid_data = xoid_data[1]
if xodd_data is not None:
    xodd_data = xodd_data[1]   
print(u'{} - {} - {}'.format(xoid_data,xodd_data,name))

但是在上一页JSON是不同的。我从“文本”中提取了id,并使用“奇数”获取数据,但是在这里我看到了很多“奇数”,这让我感到困惑。

JSON如何在下一页上工作? 如何获得类似上一页的结果? (例如:

大于/小于+155.5-3.06-1.31

上方/下方+156.5-2.82-1.35

上方/下方+157.5-2.61-1.41

上方/下方+158.5-2.43-1.47

上方/下方+159.5-2.27-1.54

上方/下方+160.5-2.12-1.61

上方/下方+161.5-2.00-1.67

  1. https://www.oddsportal.com/basketball/greece/greek-cup/promitheas-panathinaikos-MTkEXywD/inplay-odds/#over-under;1

我对下载文本很感兴趣,例如“ 1st Quarter 7”(桌子上方2厘米)。 我想在JSON中找到答案:

https://fb.oddsportal.com/feed/postmatchscore/3-MTkEXywD-yj837.dat?_=1573399835075

但与第一个问题类似,我不了解JSON在该网站上的工作方式

预先感谢您的帮助。

b50409346 回答:我不明白JSON在此网站上的运作方式

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3128642.html

大家都在问