zuqiu.py 31 KB

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