zuqiu.py 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. # -*- coding: utf-8 -*-
  2. import copy
  3. import json
  4. import time
  5. import redis
  6. import scrapy
  7. from scrapy.http import Request
  8. from ..items import Zuqiu
  9. import datetime
  10. from ..settings import R_HOST, R_PASSWORD, R_POST, R_DB
  11. class ZuqiuSpider(scrapy.Spider):
  12. name = 'zuqiu'
  13. to_day = datetime.datetime.now()
  14. # print(to_day.year, to_day)
  15. allowed_domains = ['hg3535z.com']
  16. custom_settings = {
  17. "ITEM_PIPELINES": {
  18. 'hg3535.pipeline.zuqiu.Zuqiupipeline': 300,
  19. },
  20. 'LOG_LEVEL': 'DEBUG',
  21. 'LOG_FILE': "./log/zuqiu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day),
  22. }
  23. # rls = redis.Redis(host=R_HOST, port=R_POST, db=R_DB, password=R_PASSWORD)
  24. def start_requests(self):
  25. for y in range(1, 4):
  26. for i in range(10):
  27. url = "https://odata.yonghuai5515.com/odds6i/d/getodds/zh-cn/sid/1/pt/{}/ubt/am/pn/{}/sb/2/dc/null/pid/0".format(y, i)
  28. yield scrapy.Request(url=url, callback=self.parse, dont_filter=True, meta={'pt': y})
  29. def parse(self, response):
  30. if response.status == 200:
  31. # cls = redis.Redis(host='192.168.0.110', port=6379, db=0)
  32. if response.text:
  33. try:
  34. datas = json.loads(response.text).get('n-ot', "").get('egs', "")
  35. except:
  36. print("为获取到数据")
  37. return
  38. pt = copy.copy(response.meta['pt'])
  39. for result in datas:
  40. new_results = result['es']
  41. for new_result in new_results:
  42. game_id = new_result['k']
  43. game_id = 3610206
  44. # up_time = str(time.time()) + '&' + 'zq'
  45. # self.rls.hset('hg3535.ball.ids', game_id, up_time)
  46. if pt == 3:
  47. url = "https://odata.yonghuai5515.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/false/ubt/am/isp/true".format(game_id)
  48. yield Request(url=url, callback=self.parse_each, dont_filter=True, meta={'pt': pt})
  49. if pt == 2:
  50. url = "https://odata.yonghuai5515.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/false/ubt/am/isp/false".format(game_id)
  51. yield Request(url=url, callback=self.parse_each, dont_filter=True, meta={'pt': pt})
  52. if pt == 1:
  53. url = "https://odata.yonghuai5515.com/odds6i/d/getamodds/zh-cn/eid/{}/iip/false/ubt/am/isp/false".format(game_id)
  54. yield Request(url=url, callback=self.parse_each, dont_filter=True, meta={'pt': pt})
  55. def parse_each(self, response):
  56. if response.status == 200:
  57. # 球队进球数 大小
  58. try:
  59. r_data = json.loads(response.text)['eg']
  60. datas = r_data['es']
  61. league_id = r_data['c']['k']
  62. # 联赛名
  63. league_name = r_data['c']['n']
  64. except:
  65. datas = ""
  66. league_id = ""
  67. # 联赛名
  68. league_name = ""
  69. pt = response.meta['pt']
  70. if datas:
  71. item = Zuqiu()
  72. full_dict = {}
  73. half_dict = {}
  74. full_dict_rule = {}
  75. half_dict_rule = {}
  76. horn_ou_dict = {}
  77. horn_ou_dict_rule = {}
  78. horn_oe_dict = {}
  79. horn_oe_dict_rule = {}
  80. horn_team = {}
  81. for data in datas:
  82. try:
  83. ctid = data['pci']['ctid']
  84. except:
  85. ctid = ""
  86. if ctid == 0:
  87. # 比赛id
  88. game_id = str(data['k'])
  89. # 球队1
  90. team_home = data['i'][0]
  91. # 球队2
  92. team_guest = data['i'][1]
  93. # 数量(97>)
  94. number = data['i'][2]
  95. # 下半场
  96. half_way = data['i'][12]
  97. # 角球或者其他
  98. try:
  99. corner_ball = data['pci']['ctn']
  100. except:
  101. corner_ball = 0
  102. # 日期
  103. data_game = data['i'][4]
  104. # 开赛时间
  105. time_game = data['i'][5]
  106. # 让球------------------------------------------------------------------------------------------------------------------
  107. try:
  108. concedes = data['o']['ah']['v']
  109. new_concedes = [concedes[i] for i in range(len(concedes)) if i % 2 is 1]
  110. concede_homes = [new_concedes[i] for i in range(len(new_concedes)) if i % 2 is 0]
  111. concede_home_rule = [concede_homes[i] for i in range(len(concede_homes)) if i % 2 is 0]
  112. # concede_home
  113. concede_guests = [new_concedes[i] for i in range(len(new_concedes)) if i % 2 is 1]
  114. # concede_guest_rule
  115. concede_guest_rule = [concede_guests[i] for i in range(len(concede_guests)) if
  116. i % 2 == 0]
  117. if pt == 3:
  118. concede_guest = [round(float(concede_guests[i]) - 1, 2) for i in range(len(concede_guests)) if i % 2 is 1]
  119. concede_home = [round(float(concede_homes[i]) - 1, 2) for i in range(len(concede_homes)) if i % 2 is 1]
  120. else:
  121. concede_guest = [concede_guests[i] for i in range(len(concede_guests)) if i % 2 is 1]
  122. concede_home = [concede_homes[i] for i in range(len(concede_homes)) if i % 2 is 1]
  123. except:
  124. concede_guest = ""
  125. concede_guest_rule = ""
  126. concede_home = ""
  127. concede_home_rule = ""
  128. # 上半场让球half_concede-------------------------------------------------------------------------------------------------
  129. try:
  130. half_concedes = data['o']['ah1st']['v']
  131. new_half_concedes = [half_concedes[i] for i in range(len(half_concedes)) if i % 2 is 1]
  132. new_half_concede_homes = [new_half_concedes[i] for i in range(len(new_half_concedes)) if i % 2 == 0]
  133. # half_concede_home_rule
  134. half_concede_home_rule = [new_half_concede_homes[i] for i in
  135. range(len(new_half_concede_homes)) if i % 2 == 0]
  136. # concede_home
  137. half_concede_guests = [new_half_concedes[i] for i in range(len(new_half_concedes)) if i % 2 is 1]
  138. # concede_guest_rule
  139. half_concede_guest_rule = [half_concede_guests[i] for i in
  140. range(len(half_concede_guests)) if i % 2 == 0]
  141. if pt == 3:
  142. half_concede_home = [round(float(new_half_concede_homes[i]) - 1, 2) for i in range(len(new_half_concede_homes)) if
  143. i % 2 is 1]
  144. half_concede_guest = [round(float(half_concede_guests[i]) - 1, 2) for i in range(len(half_concede_guests)) if
  145. i % 2 is 1]
  146. else:
  147. half_concede_home = [new_half_concede_homes[i] for i in range(len(new_half_concede_homes)) if i % 2 is 1]
  148. half_concede_guest = [half_concede_guests[i] for i in range(len(half_concede_guests)) if i % 2 is 1]
  149. except:
  150. half_concede_home_rule = ""
  151. half_concede_home = ""
  152. half_concede_guest_rule = ""
  153. half_concede_guest = ""
  154. # 全场大小size 进球大小---------------------------------------------------------------------------------------------------
  155. try:
  156. sizes = data['o']['ou']['v']
  157. new_sizes = [sizes[i] for i in range(len(sizes)) if i % 2 is 1]
  158. size_homes = [new_sizes[i] for i in range(len(new_sizes)) if i % 2 is 0]
  159. # size_home_rule
  160. size_home_rule = [size_homes[i] for i in range(len(size_homes)) if i % 2 is 0]
  161. # size_home
  162. size_guests = [new_sizes[i] for i in range(len(new_sizes)) if i % 2 is 1]
  163. # size_guest_rule
  164. size_guest_rule = [size_guests[i] for i in range(len(size_guests)) if i % 2 is 0]
  165. # csize_guest
  166. if pt == 3:
  167. size_guest = [round(float(size_guests[i]) - 1, 2) for i in range(len(size_guests)) if i % 2 is 1]
  168. size_home = [round(float(size_homes[i]) - 1, 2) for i in range(len(size_homes)) if i % 2 is 1]
  169. else:
  170. size_guest = [size_guests[i] for i in range(len(size_guests)) if i % 2 is 1]
  171. size_home = [size_homes[i] for i in range(len(size_homes)) if i % 2 is 1]
  172. except:
  173. size_guest = ""
  174. size_guest_rule = ""
  175. size_home = ""
  176. size_home_rule = ""
  177. # 上半场大小 进球大小 half_size-------------------------------------------------------------------------------------------
  178. try:
  179. half_sizes = data['o']['ou1st']['v']
  180. new_half_sizes = [half_sizes[i] for i in range(len(half_sizes)) if i % 2 is 1]
  181. half_size_homes = [new_half_sizes[i] for i in range(len(new_half_sizes)) if i % 2 is 0]
  182. # size_home_rule
  183. half_size_home_rule = [half_size_homes[i] for i in range(len(half_size_homes)) if
  184. i % 2 is 0]
  185. half_size_guests = [new_half_sizes[i] for i in range(len(new_half_sizes)) if i % 2 is 1]
  186. # half_size_guest_rule 客队
  187. half_size_guest_rule = [half_size_guests[i] for i in range(len(half_size_guests)) if
  188. i % 2 is 0]
  189. # half_size_guest
  190. if pt == 3:
  191. half_size_guest = [round(float(half_size_guests[i]) - 1, 2) for i in range(len(half_size_guests)) if
  192. i % 2 is 1]
  193. half_size_home = [round(float(half_size_homes[i]) - 1, 2) for i in range(len(half_size_homes)) if
  194. i % 2 is 1]
  195. else:
  196. half_size_guest = [half_size_guests[i] for i in range(len(half_size_guests)) if
  197. i % 2 is 1]
  198. half_size_home = [half_size_homes[i] for i in range(len(half_size_homes)) if i % 2 is 1]
  199. except:
  200. half_size_guest = ""
  201. half_size_guest_rule = ""
  202. half_size_home = ""
  203. half_size_home_rule = ""
  204. # 全场总进球 total_goal--------------------------------------------------------------------------------------------------
  205. total_goal = {}
  206. try:
  207. total_goals = data['o']['tg']['v']
  208. new_total_goals = [total_goals[i] for i in range(len(total_goals)) if i % 2 is 1]
  209. total_goal["tg0"] = round(float(new_total_goals[0]) - 1, 2)
  210. total_goal["tg1"] = round(float(new_total_goals[1]) - 1, 2)
  211. total_goal["tg2"] = round(float(new_total_goals[2]) - 1, 2)
  212. total_goal["tg3"] = round(float(new_total_goals[3]) - 1, 2)
  213. except:
  214. total_goal["tg0"] = ""
  215. total_goal["tg1"] = ""
  216. total_goal["tg2"] = ""
  217. total_goal["tg3"] = ""
  218. # 总进球上半场 half_total_goal-------------------------------------------------------------------------------------------
  219. try:
  220. half_total_goals = data['o']['tg1st']['v']
  221. new_half_total_goals = [half_total_goals[i] for i in range(len(half_total_goals)) if i % 2 is 1]
  222. total_goal["tg0_h"] = round(float(new_half_total_goals[0]) - 1, 2)
  223. total_goal["tg1_h"] = round(float(new_half_total_goals[1]) - 1, 2)
  224. total_goal["tg2_h"] = round(float(new_half_total_goals[2]) - 1, 2)
  225. total_goal["tg3_h"] = round(float(new_half_total_goals[3]) - 1, 2)
  226. except:
  227. total_goal["tg0_h"] = ""
  228. total_goal["tg1_h"] = ""
  229. total_goal["tg2_h"] = ""
  230. total_goal["tg3_h"] = ""
  231. # 早盘 半场/全场---------------------------------------------------------------------------------------------------------
  232. half_full = {}
  233. new_lists = ["hfhh", "hfhd", "hfhg", "hfdh", "hfdd", "hfdg", "hfgh", "hfgd", "hfgg"]
  234. # 早盘 半场/全场
  235. try:
  236. half_fulls = data['o']['hf']['v']
  237. new_half_fulls = [half_fulls[i] for i in range(len(half_fulls)) if i % 2 is 1]
  238. for index, value in enumerate(new_lists):
  239. half_full[value] = round(float(new_half_fulls[index]) - 1, 2)
  240. except:
  241. for index, value in enumerate(new_lists):
  242. half_full[value] = ""
  243. # 早盘 最先/最后进球 最先进球 ---------------------------------------------------------------------------------------------
  244. first_last_ball = {}
  245. try:
  246. first_balls = data['o']['ttslast']['v']
  247. first_ball = [first_balls[i] for i in range(len(first_balls)) if i % 2 is 1]
  248. first_last_ball['flbfh'] = round(float(first_ball[0]) - 1, 2)
  249. first_last_ball['flbfg'] = round(float(first_ball[1]) - 1, 2)
  250. except:
  251. pass
  252. # 早盘 最先/最后进球 最后进球
  253. try:
  254. last_balls = data['o']['tts1st']['v']
  255. last_ball = [last_balls[i] for i in range(len(last_balls)) if i % 2 is 1]
  256. first_last_ball['flblh'] = round(float(last_ball[0]) - 1, 2)
  257. first_last_ball['flblg'] = round(float(last_ball[1]) - 1, 2)
  258. first_last_ball['flbn'] = round(float(last_ball[2]) - 1, 2)
  259. except:
  260. pass
  261. # 全场独赢capot ---------------------------------------------------------------------------------------------------------
  262. try:
  263. capots = data['o']['1x2']['v']
  264. new_capots = [capots[i] for i in range(len(capots)) if i % 2 is 1]
  265. capot_home = round(float(new_capots[0]) - 1, 2)
  266. capot_guest = round(float(new_capots[1]) - 1, 2)
  267. capot_dogfall = round(float(new_capots[2]) - 1, 2)
  268. except:
  269. capot_home = ""
  270. capot_guest = ""
  271. capot_dogfall = ""
  272. # 上半场独赢capot
  273. try:
  274. half_capots = data['o']['1x21st']['v']
  275. new_half_capots = [half_capots[i] for i in range(len(half_capots)) if i % 2 is 1]
  276. half_capot_home = round(float(new_half_capots[0]) - 1, 2)
  277. half_capot_guest = round(float(new_half_capots[1]) - 1, 2)
  278. half_capot_dogfall = round(float(new_half_capots[2]) - 1, 2)
  279. except:
  280. half_capot_home = ""
  281. half_capot_guest = ""
  282. half_capot_dogfall = ""
  283. # 全场入球:单/双 odd_even------------------------------------------------------------------------------------------------
  284. try:
  285. odd_evens = data['o']['oe']['v']
  286. new_odd_evens = [odd_evens[i] for i in range(len(odd_evens)) if i % 2 is 1]
  287. if pt is 3:
  288. odd_even_odd = round(float(new_odd_evens[0]) - 1, 2)
  289. odd_even_even = round(float(new_odd_evens[1]) - 1, 2)
  290. else:
  291. odd_even_odd = round(float(new_odd_evens[0]), 2)
  292. odd_even_even = round(float(new_odd_evens[1]), 2)
  293. except:
  294. odd_even_odd = ""
  295. odd_even_even = ""
  296. # 半场入球:单/双 half_odd_even
  297. try:
  298. half_odd_evens = data['o']['oe1st']['v']
  299. new_half_odd_evens = [half_odd_evens[i] for i in range(len(half_odd_evens)) if i % 2 is 1]
  300. if pt == 3:
  301. half_odd_even_odd = round(float(new_half_odd_evens[0]) - 1, 2)
  302. half_odd_even_even = round(float(new_half_odd_evens[1]) - 1, 2)
  303. else:
  304. half_odd_even_odd = new_half_odd_evens[0]
  305. half_odd_even_even = new_half_odd_evens[1]
  306. except:
  307. half_odd_even_odd = ""
  308. half_odd_even_even = ""
  309. bodan_data = {}
  310. # 波胆------------------------------------------------------------------------------------------------------------------
  311. try:
  312. bodans = data['o']['cs']['v']
  313. one_list = ["b10", "b20", "b21", "b30", "b31", "b32", "b40", "b41", "b42", "b43"]
  314. two_list = ["b01", "b02", "b12", "b03", "b13", "b23", "b04", "b14", "b24", "b34"]
  315. three_list = ["b00", "b11", "b22", "b33", "b44"]
  316. new_bodans = [bodans[i] for i in range(len(bodans)) if i % 2 is 1]
  317. new_bodan = new_bodans[0:20]
  318. # 主队bodan_home
  319. bodan_home = [new_bodan[i] for i in range(len(new_bodan)) if i % 2 is 0]
  320. for index, t in enumerate(one_list):
  321. bodan_data[t] = round(float(bodan_home[index]) - 1, 2)
  322. # 客队bodan_guest
  323. bodan_guest = [new_bodan[i] for i in range(len(new_bodan)) if i % 2 is 1]
  324. for y, z in enumerate(two_list):
  325. bodan_data[z] = round(float(bodan_guest[y]) - 1, 2)
  326. bodan_dogfall = new_bodans[-6:-1]
  327. for a, b in enumerate(three_list):
  328. bodan_data[b] = round(float(bodan_dogfall[a]) - 1, 2)
  329. # 其他bodan_other
  330. bodan_data['bo'] = round(float(new_bodans[-1]) - 1, 2)
  331. except:
  332. pass
  333. try:
  334. half_bodans = data['o']['cs1st']['v']
  335. new_half_bodans = [half_bodans[i] for i in range(len(half_bodans)) if i % 2 is 1]
  336. new_one = ["b10_h", "b20_h", "b21_h", "b30_h", "b31_h", "b32_h"]
  337. new_two = ["b01_h", "b02_h", "b12_h", "b03_h", "b13_h", "b23_h"]
  338. new_three = ["b00_h", "b11_h", "b22_h", "b33_h"]
  339. halfbodan = new_half_bodans[0:12]
  340. half_bodan_home = [halfbodan[i] for i in range(len(halfbodan)) if i % 2 is 0]
  341. # 队1
  342. for index, t in enumerate(new_one):
  343. bodan_data[t] = round(float(half_bodan_home[index]) - 1, 2)
  344. # 队2
  345. half_bodan_guest = [halfbodan[i] for i in range(len(halfbodan)) if i % 2 is 1]
  346. for y, z in enumerate(new_two):
  347. bodan_data[z] = round(float(half_bodan_guest[y]) - 1, 2)
  348. # 和/平
  349. half_bodan_dogfall = new_half_bodans[-5:-1]
  350. for a, b in enumerate(new_three):
  351. bodan_data[b] = round(float(half_bodan_dogfall[a]) - 1, 2)
  352. # 其他
  353. bodan_data['bo_h'] = round(float(new_half_bodans[-1]) - 1, 2)
  354. except:
  355. pass
  356. if ctid == 1:
  357. # 角球数据
  358. horn_team['horn_home'] = data['i'][0]
  359. horn_team['horn_guest'] = data['i'][1]
  360. horn_team['horn_scoreh'] = data['i'][10]
  361. horn_team['horn_scoreg'] = data['i'][11]
  362. horn_team['horn_id'] = str(data['k'])
  363. try:
  364. horn_ou = data['o']['ou']['v']
  365. except:
  366. horn_ou = ''
  367. if horn_ou:
  368. horn_ou_dict['cbgb'] = horn_ou[5]
  369. horn_ou_dict['cbgs'] = horn_ou[7]
  370. horn_ou_dict_rule['cbgb'] = horn_ou[1]
  371. horn_ou_dict_rule['cbgs'] = horn_ou[3]
  372. try:
  373. horn_ou1st = data['o']['ou1st']['v']
  374. except:
  375. horn_ou1st = ''
  376. if horn_ou1st:
  377. horn_ou_dict['cbgb_h'] = horn_ou1st[5]
  378. horn_ou_dict['cbgs_h'] = horn_ou1st[7]
  379. horn_ou_dict_rule['cbgb_h'] = horn_ou1st[1]
  380. horn_ou_dict_rule['cbgs_h'] = horn_ou1st[3]
  381. try:
  382. horn_oe = data['o']['oe']['v']
  383. except:
  384. horn_oe = ''
  385. if horn_oe:
  386. horn_oe_dict['cbtss'] = horn_oe[1]
  387. horn_oe_dict['cbtsd'] = horn_oe[3]
  388. horn_oe_dict_rule['cbtss'] = '单'
  389. horn_oe_dict_rule['cbtsd'] = '双'
  390. try:
  391. horn_oe1st = data['o']['oe1st']['v']
  392. except:
  393. horn_oe1st = ''
  394. if horn_oe1st:
  395. horn_oe_dict['cbtss_h'] = horn_oe1st[1]
  396. horn_oe_dict['cbtsd_h'] = horn_oe1st[3]
  397. horn_oe_dict_rule['cbtss_h'] = '单'
  398. horn_oe_dict_rule['cbtsd_h'] = '双'
  399. if ctid == 12:
  400. try:
  401. home_data = data['o']['ou']['v']
  402. # 球队进球 大条件
  403. full_dict_rule['tbhb'] = home_data[1]
  404. # 球队进球小条件
  405. full_dict_rule['tbhs'] = home_data[3]
  406. if pt == 3:
  407. # 球队进球大赔率
  408. full_dict['tbhb'] = round(float(home_data[5]) - 1, 2)
  409. # 球队进球小赔率
  410. full_dict['tbhs'] = round(float(home_data[7]) - 1, 2)
  411. else:
  412. # 球队进球大赔率
  413. full_dict['tbhb'] = home_data[5]
  414. # 球队进球小赔率
  415. full_dict['tbhs'] = home_data[7]
  416. except:
  417. full_dict['tbhs'] = ""
  418. full_dict_rule['tbhs'] = ""
  419. full_dict['tbhb'] = ""
  420. full_dict_rule['tbhb'] = ""
  421. try:
  422. half_home_data = data['o']['ou1st']['v']
  423. half_dict_rule['tbhb_h'] = half_home_data[1]
  424. half_dict_rule['tbhs_h'] = half_home_data[3]
  425. if pt == 3:
  426. half_dict['tbhb_h'] = round(float(half_home_data[5]) - 1, 2)
  427. half_dict['tbhs_h'] = round(float(half_home_data[7]) - 1, 2)
  428. else:
  429. half_dict['tbhb_h'] = half_home_data[5]
  430. half_dict['tbhs_h'] = half_home_data[7]
  431. except:
  432. half_dict_rule['tbhb_h'] = ""
  433. half_dict['tbhb_h'] = ""
  434. half_dict_rule['tbhs_h'] = ""
  435. half_dict['tbhs_h'] = ""
  436. if ctid == 13:
  437. try:
  438. guest_data = data['o']['ou']['v']
  439. full_dict_rule['tbgb'] = guest_data[1]
  440. full_dict_rule['tbgs'] = guest_data[3]
  441. if pt == 3:
  442. full_dict['tbgb'] = round(float(guest_data[5]) - 1, 2)
  443. full_dict['tbgs'] = round(float(guest_data[7]) - 1, 2)
  444. else:
  445. full_dict['tbgb'] = guest_data[5]
  446. full_dict['tbgs'] = guest_data[7]
  447. except:
  448. full_dict_rule['tbgb'] = ""
  449. full_dict['tbgb'] = ""
  450. full_dict_rule['tbgs'] = ""
  451. full_dict['tbgs'] = ''
  452. try:
  453. half_guest_data = data['o']['ou1st']['v']
  454. half_dict_rule['tbgb_h'] = half_guest_data[1]
  455. half_dict_rule['tbgs_h'] = half_guest_data[3]
  456. if pt == 3:
  457. half_dict['tbgb_h'] = round(float(half_guest_data[5]) - 1, 2)
  458. half_dict['tbgs_h'] = round(float(half_guest_data[7]) - 1, 2)
  459. else:
  460. half_dict['tbgb_h'] = half_guest_data[5]
  461. half_dict['tbgs_h'] = half_guest_data[7]
  462. except:
  463. half_dict_rule['tbgb_h'] = ""
  464. half_dict['tbgb_h'] = ""
  465. half_dict_rule['tbgs_h'] = ""
  466. half_dict['tbgs_h'] = ""
  467. item['league_id'] = league_id
  468. item['league_name'] = league_name
  469. item['pt'] = pt
  470. item['game_id'] = game_id
  471. item['team_home'] = team_home
  472. item['team_guest'] = team_guest
  473. item['number'] = number
  474. item['data_game'] = data_game
  475. item['time_game'] = time_game
  476. item['corner_ball'] = corner_ball
  477. # 波胆
  478. item['bodan_data'] = bodan_data
  479. # 早盘入球数单双
  480. item["odd_even_odd"] = odd_even_odd
  481. item["odd_even_even"] = odd_even_even
  482. item["half_odd_even_odd"] = half_odd_even_odd
  483. item["half_odd_even_even"] = half_odd_even_even
  484. item['total_goal'] = total_goal
  485. item["half_capot_home"] = half_capot_home
  486. item["half_capot_guest"] = half_capot_guest
  487. item["half_capot_dogfall"] = half_capot_dogfall
  488. item["capot_home"] = capot_home
  489. item["capot_guest"] = capot_guest
  490. item["capot_dogfall"] = capot_dogfall
  491. item["first_last_ball"] = first_last_ball
  492. item["half_full"] = half_full
  493. item["half_size_guest"] = half_size_guest
  494. item["half_size_guest_rule"] = half_size_guest_rule
  495. item["half_size_home"] = half_size_home
  496. item["half_size_home_rule"] = half_size_home_rule
  497. # 全场大小
  498. item["size_guest"] = size_guest
  499. item["size_guest_rule"] = size_guest_rule
  500. item["size_home"] = size_home
  501. item["size_home_rule"] = size_home_rule
  502. # 上半场让球
  503. item["half_concede_home_rule"] = half_concede_home_rule
  504. item["half_concede_home"] = half_concede_home
  505. item["half_concede_guest_rule"] = half_concede_guest_rule
  506. item["half_concede_guest"] = half_concede_guest
  507. # 全场让球
  508. item["concede_guest"] = concede_guest
  509. item["concede_guest_rule"] = concede_guest_rule
  510. item["concede_home"] = concede_home
  511. item["concede_home_rule"] = concede_home_rule
  512. item['full_data'] = full_dict
  513. item['half_data'] = half_dict
  514. item['full_data_rule'] = full_dict_rule
  515. item['half_data_rule'] = half_dict_rule
  516. item['horn_ou_dict'] = horn_ou_dict
  517. item['horn_ou_dict_rule'] = horn_ou_dict_rule
  518. item['horn_oe_dict'] = horn_oe_dict
  519. item['horn_oe_dict_rule'] = horn_oe_dict_rule
  520. item['horn_team'] = horn_team
  521. yield item