fix:
This commit is contained in:
parent
95aa91fd8e
commit
9f6faea23d
|
|
@ -0,0 +1,2 @@
|
||||||
|
sql1 = """
|
||||||
|
"""
|
||||||
|
|
@ -43,6 +43,15 @@ class Lottery(object):
|
||||||
print("close the db session...")
|
print("close the db session...")
|
||||||
self.db.close()
|
self.db.close()
|
||||||
|
|
||||||
|
def get_last_id_by_sum_num(self, sum_num):
|
||||||
|
"""
|
||||||
|
根据总和获取id
|
||||||
|
"""
|
||||||
|
last_id = self.db.query(self._Model.id).filter_by(sum_num=sum_num).order_by(self._Model.id.desc()).first()
|
||||||
|
if last_id is not None:
|
||||||
|
return last_id[0]
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def insert(self, draw_issue, draw_date, draw_code, **kwargs):
|
def insert(self, draw_issue, draw_date, draw_code, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
import requests
|
|
||||||
from furl import furl
|
|
||||||
import time
|
|
||||||
import json
|
|
||||||
|
|
||||||
file = open("data.json", "w+")
|
|
||||||
|
|
||||||
base_url = "https://www.ttyingqiu.com/"
|
|
||||||
f = furl(base_url)
|
|
||||||
|
|
||||||
f.path = "/static/no_cache/league/zc/jsbf/ttyq2020/jsbf_2022-11-06.json"
|
|
||||||
f.args["v"] = int(time.time()*1000)
|
|
||||||
print(f.url)
|
|
||||||
print(r.status_code)
|
|
||||||
print(r.json())
|
|
||||||
file.write(json.dumps(r.json()))
|
|
||||||
file.close()
|
|
||||||
|
|
||||||
|
|
||||||
url = "/static/no_cache/league/zc/jsbf/ttyq2020/jczq/jsbf_2022-11-06.json?v=1667799791084"
|
|
||||||
url = "https://www.ttyingqiu.com/static/no_cache/league/zc/jsbf/ttyq2020/jczq/2022-11-06/oz_407_6.json?v=1667799791169"
|
|
||||||
|
|
||||||
match_list = data["matchList"]
|
|
||||||
|
|
@ -1,65 +1,98 @@
|
||||||
import sys
|
import sys
|
||||||
sys.path.append("/root/documents/py_scripts")
|
sys.path.append("/root/documents/py_scripts")
|
||||||
|
|
||||||
from typing import Optional
|
|
||||||
from furl import furl
|
from furl import furl
|
||||||
from requests_html import HTML, HTMLSession
|
from requests_html import HTML, HTMLSession
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
class Jczq(object):
|
from lottery.football import Foootball
|
||||||
|
from model.football_match import FootballMatch
|
||||||
|
from model.football_match_spf_odds import FootballMatchSpfOdd
|
||||||
|
from model.football_match_bf_odds import FootballMatchBfOdd
|
||||||
|
from model.football_match_bqc_odds import FootballMatchBqcOdd
|
||||||
|
from model.football_match_zjq_odds import FootballMatchZjqOdd
|
||||||
|
|
||||||
|
|
||||||
|
class Jczq(Foootball):
|
||||||
'''
|
'''
|
||||||
竞彩足球赔率获取
|
竞彩足球赔率获取
|
||||||
'''
|
'''
|
||||||
_base_url = furl("https://trade.500.com/jczq/?g=2")
|
_base_url = furl("https://trade.500.com/jczq/?g=2&playid=312")
|
||||||
|
|
||||||
def __init__(self, date_str):
|
def __init__(self, date_str):
|
||||||
|
super().__init__()
|
||||||
self.session = HTMLSession()
|
self.session = HTMLSession()
|
||||||
self._base_url.args["date"] = date_str
|
self._base_url.args["date"] = date_str
|
||||||
|
|
||||||
def get_spf_odds(self, d: Optional[str]=None):
|
def get_odds(self):
|
||||||
self._base_url.args["playid"] = 312
|
|
||||||
if d is not None:
|
|
||||||
self._base_url.args["date"] = d
|
|
||||||
# print(self._base_url.url)
|
# print(self._base_url.url)
|
||||||
r = self.session.get(self._base_url)
|
r = self.session.get(self._base_url)
|
||||||
|
|
||||||
bet_trs = r.html.find("tr.bet-tb-tr")
|
bet_trs = r.html.find("tr.bet-tb-tr")
|
||||||
print(len(bet_trs))
|
|
||||||
|
|
||||||
bet_more_trs = r.html.find("tr.bet-more-wrap")
|
bet_more_trs = r.html.find("tr.bet-more-wrap")
|
||||||
print(len(bet_more_trs))
|
|
||||||
for tr in zip(bet_trs, bet_more_trs):
|
for tr in zip(bet_trs, bet_more_trs):
|
||||||
# 对应竞彩网matchId
|
# 对应竞彩网matchId
|
||||||
match_id = tr[0].attrs["data-id"]
|
match = self.db.query(FootballMatch).filter_by(issue=tr[0].attrs["data-id"]).first()
|
||||||
|
if match is not None:
|
||||||
|
continue
|
||||||
|
match = FootballMatch()
|
||||||
|
match.issue = tr[0].attrs["data-id"]
|
||||||
match_num = tr[0].attrs["data-matchnum"]
|
match_num = tr[0].attrs["data-matchnum"]
|
||||||
league_name = tr[0].attrs["data-simpleleague"]
|
match.league_name = tr[0].attrs["data-simpleleague"]
|
||||||
home_name = tr[0].attrs["data-homesxname"]
|
match.home_name = tr[0].attrs["data-homesxname"]
|
||||||
away_name = tr[0].attrs["data-awaysxname"]
|
match.away_name = tr[0].attrs["data-awaysxname"]
|
||||||
match_date = tr[0].attrs["data-matchdate"] + tr[0].attrs["data-matchtime"]
|
match.match_date = tr[0].attrs["data-matchdate"] + " " + tr[0].attrs["data-matchtime"]
|
||||||
buyendtime = tr[0].attrs["data-buyendtime"]
|
match.buy_end_time = tr[0].attrs["data-buyendtime"]
|
||||||
rangqiu = tr[0].attrs["data-rangqiu"]
|
match.rq_count = tr[0].attrs["data-rangqiu"]
|
||||||
|
match.score = tr[0].find("i.team-bf", first=True).text
|
||||||
|
self.db.add(match)
|
||||||
|
self.db.commit()
|
||||||
|
match_id = match.id
|
||||||
|
match_issue = match.issue
|
||||||
# 胜平负
|
# 胜平负
|
||||||
nspf = tr[0].find("td.td-betbtn div.itm-rangB1", first=True)
|
nspf = tr[0].find("td.td-betbtn div.itm-rangB1", first=True)
|
||||||
betbtn_ok = nspf.find("p[class$='betbtn-ok']", first=True)
|
betbtn_ok = nspf.find("p[class$='betbtn-ok']", first=True)
|
||||||
|
# 比分
|
||||||
if betbtn_ok is not None:
|
if betbtn_ok is not None:
|
||||||
result = betbtn_ok.attrs["data-value"]
|
result = betbtn_ok.attrs["data-value"]
|
||||||
nspf_odds = {i.attrs["data-value"]: i.attrs["data-sp"] for i in nspf.find("p.betbtn")}
|
nspf_odds = {i.attrs["data-value"]: i.attrs["data-sp"] for i in nspf.find("p.betbtn")}
|
||||||
|
|
||||||
# 让球胜平负
|
# 让球胜平负
|
||||||
spf = tr[0].find("td.td-betbtn div.itm-rangB2", first=True)
|
spf = tr[0].find("td.td-betbtn div.itm-rangB2", first=True)
|
||||||
rq_result = spf.find("p[class$='betbtn-ok']", first=True).attrs["data-value"]
|
rq_result = spf.find("p[class$='betbtn-ok']", first=True).attrs["data-value"]
|
||||||
spf_odds = {i.attrs["data-value"]: i.attrs["data-sp"] for i in spf.find("p.betbtn")}
|
spf_odds = {i.attrs["data-value"]: i.attrs["data-sp"] for i in spf.find("p.betbtn")}
|
||||||
|
spf_model = FootballMatchSpfOdd(match_id=match_id, issue=match_issue, rq_count=match.rq_count, rq_result=rq_result)
|
||||||
|
spf_model.win = nspf_odds["3"]
|
||||||
|
spf_model.draw = nspf_odds["1"]
|
||||||
|
spf_model.lost = nspf_odds["0"]
|
||||||
|
spf_model.rq_win = spf_odds["3"]
|
||||||
|
spf_model.rq_draw = spf_odds["1"]
|
||||||
|
spf_model.rq_lost = spf_odds["0"]
|
||||||
|
self.db.add(spf_model)
|
||||||
# 半全场
|
# 半全场
|
||||||
bqc = tr[1].find("p[data-type='bqc']")
|
bqc = tr[1].find("p[data-type='bqc']")
|
||||||
bqc_odds = {i.attrs["data-value"]: i.attrs["data-sp"] for i in bqc}
|
bqc_odds = {"_" + i.attrs["data-value"].replace("-", "_"): i.attrs["data-sp"] for i in bqc}
|
||||||
bqc_result = tr[1].find("p[class$='sbetbtn-ok'][data-type='bqc']", first=True).attrs["data-value"]
|
bqc_result = tr[1].find("p[class$='sbetbtn-ok'][data-type='bqc']", first=True).attrs["data-value"]
|
||||||
|
bqc_model = FootballMatchBqcOdd(match_id=match_id, issue=match_issue, result=bqc_result, **bqc_odds)
|
||||||
|
self.db.add(bqc_model)
|
||||||
# 比分
|
# 比分
|
||||||
bf = tr[1].find("p[data-type='bf']")
|
bf = tr[1].find("p[data-type='bf']")
|
||||||
bf_odds = {i.attrs["data-value"]: i.attrs["data-sp"] for i in bf}
|
bf_odds = {i.attrs["data-value"]: i.attrs["data-sp"] for i in bf}
|
||||||
|
bf_odds = {("_" + k.replace(":", "_")).replace("_胜其它", "win_others").replace("_平其它", "draw_others").replace("_负其它", "lost_others"): bf_odds[k] for k in bf_odds.keys()}
|
||||||
bf_result = tr[1].find("p[class$='sbetbtn-ok'][data-type='bf']", first=True).attrs["data-value"]
|
bf_result = tr[1].find("p[class$='sbetbtn-ok'][data-type='bf']", first=True).attrs["data-value"]
|
||||||
|
bf_model = FootballMatchBfOdd(match_id=match_id, issue=match_issue, result=bf_result, **bf_odds)
|
||||||
|
self.db.add(bf_model)
|
||||||
# 进球数
|
# 进球数
|
||||||
jqs = tr[1].find("p[data-type='jqs']")
|
jqs = tr[1].find("p[data-type='jqs']")
|
||||||
jqs_odds = {i.attrs["data-value"]: i.attrs["data-sp"] for i in jqs}
|
jqs_odds = {"ball_" + i.attrs["data-value"].replace("7", "7_plus"): i.attrs["data-sp"] for i in jqs}
|
||||||
jqs_result = tr[1].find("p[class$='sbetbtn-ok'][data-type='jqs']", first=True).attrs["data-value"]
|
jqs_result = tr[1].find("p[class$='sbetbtn-ok'][data-type='jqs']", first=True).attrs["data-value"]
|
||||||
print(f"{home_name}-{away_name} 赔率:{nspf_odds}, 结果:{result}, 比分:{bf_result},比分赔率:{bf_odds}")
|
zjq_model = FootballMatchZjqOdd(match_id=match_id, issue=match_issue, result=jqs_result, **jqs_odds)
|
||||||
jczq = Jczq("2023-04-15")
|
self.db.add(zjq_model)
|
||||||
jczq.get_spf_odds()
|
self.db.commit()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# dates = pd.date_range(start='2023-04-15', end='2023-05-13')
|
||||||
|
# print(dates)
|
||||||
|
jczq = Jczq("2023-04-15")
|
||||||
|
jczq.get_odds()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue