lanqiu.py 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861
  1. # -*- coding: utf-8 -*-
  2. import copy
  3. import datetime
  4. import json
  5. import scrapy
  6. from scrapy.http import Request
  7. from .. items import Lanqiu
  8. def rangqiu_daxiao(inner, pt):
  9. concede = [inner[i] for i in range(len(inner)) if i % 2 is 1]
  10. # 主队让球条件赔率
  11. concedehome = [concede[i] for i in range(len(concede)) if i % 2 is 0]
  12. # 客队让球条件赔率
  13. concedeguest = [concede[i] for i in range(len(concede)) if i % 2 is 1]
  14. # 主队让球条件
  15. concede_home_rule = [concedehome[i] for i in range(len(concedehome)) if i % 2 == 0]
  16. # 客队让球条件
  17. concede_guest_rule = [concedeguest[i] for i in range(len(concedeguest)) if i % 2 == 0]
  18. # 客队让球赔率
  19. if pt is 3:
  20. concede_guest = [float(concedeguest[i]) - 1 for i in range(len(concedeguest)) if i % 2 is 1]
  21. # 主队让球赔率
  22. concede_home = [float(concedehome[i]) - 1 for i in range(len(concedehome)) if i % 2 is 1]
  23. else:
  24. concede_home = [concedehome[i] for i in range(len(concedehome)) if i % 2 is 1]
  25. concede_guest = [concedeguest[i] for i in range(len(concedeguest)) if i % 2 is 1]
  26. return concede_home_rule, concede_home, concede_guest_rule, concede_guest
  27. def danshaung_fun(inner):
  28. odd_even = [inner[i] for i in range(len(inner)) if i % 2 is 1]
  29. # 全场 总分单
  30. odd_even_odd = [odd_even[i] for i in range(len(odd_even)) if i % 2 is 0]
  31. # 全场 总分双
  32. odd_even_even = [odd_even[i] for i in range(len(odd_even)) if i % 2 is 1]
  33. return odd_even_odd, odd_even_even
  34. class LanqiuSpider(scrapy.Spider):
  35. name = "lanqiu"
  36. to_day = datetime.datetime.now()
  37. allowed_domains = ['hg3535z.com']
  38. custom_settings = {
  39. "ITEM_PIPELINES": {
  40. "hg3535.pipelines.Lanqiupipeline": 300,
  41. },
  42. 'LOG_LEVEL': 'DEBUG',
  43. 'LOG_FILE': "../hg3535/log/lanqiu_{}_{}_{}.log".format(to_day.year, to_day.month, to_day.day)
  44. }
  45. def start_requests(self):
  46. # newall_lists = ['am', 'ftht1x2', 'oe', 'tg', 'htft', 'cs', 'fglg', 'or']
  47. for y in range(1, 4):
  48. url = 'https://hg3535z.com/odds2/d/getodds?sid=2&pt='+str(y)+'&ubt=am&pn=0&sb=2&dc=null&pid=0'
  49. yield scrapy.Request(url=url, callback=self.parse, meta={'pt': y}, dont_filter=True)
  50. def parse(self, response):
  51. if response.text:
  52. try:
  53. datas = json.loads(response.text).get('n-ot', "").get('egs', "")
  54. except:
  55. datas = ""
  56. try:
  57. pt = copy.copy(response.meta['pt'])
  58. except:
  59. pt = 0
  60. if datas:
  61. # id_list = []
  62. for result in datas:
  63. new_results = result['es']
  64. for new_result in new_results:
  65. game_id = str(new_result['i'][16])
  66. if pt == 1:
  67. url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "&iip=false&ubt=am&isp=false"
  68. yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
  69. if pt == 2:
  70. url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "&iip=false&ubt=am&isp=false"
  71. yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
  72. if pt == 3:
  73. url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "&iip=false&ubt=am&isp=true"
  74. yield Request(url=url, callback=self.parse_each, meta={'pt': pt}, dont_filter=True)
  75. def parse_each(self, response):
  76. try:
  77. new_datas = json.loads(response.text)['eg']
  78. pt = response.meta['pt']
  79. lanqiu = json.loads(response.text)['i'][31]
  80. except:
  81. pt = 0
  82. new_datas = ""
  83. lanqiu = ""
  84. item = Lanqiu()
  85. if new_datas:
  86. # 联赛id
  87. league_id = new_datas.get("c", "").get("k", "")
  88. # 联赛名
  89. league_name = new_datas.get("c", "").get("n", "")
  90. new_data = new_datas.get("es", "")
  91. team_scores_dict = {}
  92. team_scores_dict_rule = {}
  93. concedes_dict = {}
  94. concedes_dict_rule = {}
  95. total_sizes_dict = {}
  96. total_sizes_dict_rule = {}
  97. odd_evens_dict = {}
  98. odd_evens_dict_rule = {}
  99. last_numbers_dict = {}
  100. capots_dict = {}
  101. data = []
  102. for result in new_data:
  103. if result['pci']['ctid'] == 0:
  104. # 比赛id
  105. game_id = str(result['k'])
  106. data.append(game_id)
  107. # 球队1
  108. team_home = result['i'][0]
  109. data.append(team_home)
  110. # 球队2
  111. team_guest = result['i'][1]
  112. data.append(team_guest)
  113. # 数量(97>)
  114. number = result['i'][2]
  115. data.append(number)
  116. # 比赛状态
  117. zhuangtai = result['i'][3]
  118. data.append(zhuangtai)
  119. # 日期
  120. data_game = result['i'][4]
  121. data.append(data_game)
  122. # 开赛时间
  123. time_game = result['i'][5]
  124. data.append(time_game)
  125. # 队1分数
  126. score_home1 = result['i'][10]
  127. data.append(score_home1)
  128. # 队2分数
  129. score_guest1 = result['i'][11]
  130. data.append(score_guest1)
  131. # 第几节
  132. jijie = result['i'][12]
  133. data.append(jijie)
  134. # 球队得分
  135. qiudui = result['pci'].get('ctn', "")
  136. data.append(qiudui)
  137. # ----------------------------------------让球分割线---------------------------------------------------------------------
  138. try:
  139. concedes = result['o']["ah"]["v"]
  140. # print(concedes)
  141. # 主队让球条件,主队让球赔率,客队让球条件,客队让球赔率
  142. concede_home_rule,concede_home,concede_guest_rule,concede_guest=rangqiu_daxiao(inner=concedes, pt=pt)
  143. concedes_dict_rule['concede_home'] = concede_home_rule
  144. concedes_dict['concede_home'] = concede_home
  145. concedes_dict_rule['concede_guest'] = concede_guest_rule
  146. concedes_dict['concede_guest'] = concede_guest
  147. except:
  148. concede_guest = ""
  149. concede_guest_rule = ""
  150. concede_home = ""
  151. concede_home_rule = ""
  152. concedes_dict_rule['concede_home'] = concede_home_rule
  153. concedes_dict['concede_home'] = concede_home
  154. concedes_dict_rule['concede_guest'] = concede_guest_rule
  155. concedes_dict['concede_guest'] = concede_guest
  156. # print(concedes_dict)
  157. try:
  158. half_concedes = result['o']["ah1st"]["v"]
  159. # 上半场 主队让球条件
  160. half_concede_home_rule, half_concede_home, half_concede_guest_rule, half_concede_guest=rangqiu_daxiao(inner=half_concedes, pt=pt)
  161. concedes_dict_rule['half_concede_home'] = half_concede_home_rule
  162. concedes_dict['half_concede_home'] = half_concede_home
  163. concedes_dict_rule['half_concede_guest'] = half_concede_guest_rule
  164. concedes_dict['half_concede_guest'] = half_concede_guest
  165. except:
  166. half_concede_home_rule = ""
  167. half_concede_home = ""
  168. half_concede_guest_rule = ""
  169. half_concede_guest = ""
  170. concedes_dict_rule['half_concede_home'] = half_concede_home_rule
  171. concedes_dict['half_concede_home'] = half_concede_home
  172. concedes_dict_rule['half_concede_guest'] = half_concede_guest_rule
  173. concedes_dict['half_concede_guest'] = half_concede_guest
  174. # 第一节让球
  175. try:
  176. one_concedes = result['o']["ahq1"]["v"]
  177. one_concede_home_rule,one_concede_home,one_concede_guest_rule,one_concede_guest = rangqiu_daxiao(inner=one_concedes, pt=pt)
  178. concedes_dict_rule['one_concede_home'] = one_concede_home_rule
  179. concedes_dict['one_concede_home'] = one_concede_home
  180. concedes_dict_rule['one_concede_guest'] = one_concede_guest_rule
  181. concedes_dict['one_concede_guest'] = one_concede_guest
  182. except:
  183. one_concede_guest = ""
  184. one_concede_guest_rule = ""
  185. one_concede_home = ""
  186. one_concede_home_rule = ""
  187. concedes_dict['one_concede_home_rule'] = one_concede_home_rule
  188. concedes_dict['one_concede_home'] = one_concede_home
  189. concedes_dict['one_concede_guest_rule'] = one_concede_guest_rule
  190. concedes_dict['one_concede_guest'] = one_concede_guest
  191. # 第二节让球
  192. try:
  193. two_concedes = result['o']["ahq2"]["v"]
  194. two_concede_home_rule,two_concede_home,two_concede_guest_rule,two_concede_guest = rangqiu_daxiao(inner=two_concedes, pt=pt)
  195. concedes_dict_rule['two_concede_home'] = two_concede_home_rule
  196. concedes_dict['two_concede_home'] = two_concede_home
  197. concedes_dict_rule['two_concede_guest'] = two_concede_guest_rule
  198. concedes_dict['two_concede_guest'] = two_concede_guest
  199. except:
  200. two_concede_guest = ""
  201. two_concede_guest_rule = ""
  202. two_concede_home = ""
  203. two_concede_home_rule = ""
  204. concedes_dict_rule['two_concede_home'] = two_concede_home_rule
  205. concedes_dict['two_concede_home'] = two_concede_home
  206. concedes_dict_rule['two_concede_guest'] = two_concede_guest_rule
  207. concedes_dict['two_concede_guest'] = two_concede_guest
  208. # 第三节让球
  209. try:
  210. three_concedes = result['o']["ahq3"]["v"]
  211. three_concede_home_rule,three_concede_home,three_concede_guest_rule,three_concede_guest = rangqiu_daxiao(inner=three_concedes, pt=pt)
  212. concedes_dict_rule['three_concede_home'] = three_concede_home_rule
  213. concedes_dict['three_concede_home'] = three_concede_home
  214. concedes_dict_rule['three_concede_guest'] = three_concede_guest_rule
  215. concedes_dict['three_concede_guest'] = three_concede_guest
  216. except:
  217. three_concede_guest = ""
  218. three_concede_guest_rule = ""
  219. three_concede_home = ""
  220. three_concede_home_rule = ""
  221. concedes_dict_rule['three_concede_home'] = three_concede_home_rule
  222. concedes_dict['three_concede_home'] = three_concede_home
  223. concedes_dict_rule['three_concede_guest'] = three_concede_guest_rule
  224. concedes_dict['three_concede_guest'] = three_concede_guest
  225. # 第四节让球
  226. try:
  227. four_concedes = result['o']["ahq4"]["v"]
  228. four_concede_home_rule,four_concede_home,four_concede_guest_rule,four_concede_guest = rangqiu_daxiao(inner=four_concedes, pt=pt)
  229. concedes_dict_rule['four_concede_home'] = four_concede_home_rule
  230. concedes_dict['four_concede_home'] = four_concede_home
  231. concedes_dict_rule['four_concede_guest'] = four_concede_guest_rule
  232. concedes_dict['four_concede_guest'] = four_concede_guest
  233. except:
  234. four_concede_guest = ""
  235. four_concede_guest_rule = ""
  236. four_concede_home = ""
  237. four_concede_home_rule = ""
  238. concedes_dict_rule['four_concede_home'] = four_concede_home_rule
  239. concedes_dict['four_concede_home'] = four_concede_home
  240. concedes_dict_rule['four_concede_guest'] = four_concede_guest_rule
  241. concedes_dict['four_concede_guest'] = four_concede_guest
  242. # ----------------------------------------总分大小分割线 - ---------------------------------------------------------------
  243. # 全场总分大小
  244. try:
  245. total_sizes = result['o']["ou"]["v"]
  246. total_sizes_big_rule,total_sizes_big,total_sizes_small_rule,total_sizes_small = rangqiu_daxiao(inner=total_sizes, pt=pt)
  247. total_sizes_dict_rule["total_size_big"] = total_sizes_big_rule
  248. total_sizes_dict["total_size_big"] = total_sizes_big
  249. total_sizes_dict_rule["total_size_small"] = total_sizes_small_rule
  250. total_sizes_dict["total_size_small"] = total_sizes_small
  251. except:
  252. total_sizes_big_rule = ""
  253. total_sizes_big = ""
  254. total_sizes_small_rule = ""
  255. total_sizes_small = ""
  256. total_sizes_dict_rule["total_size_big"] = total_sizes_big_rule
  257. total_sizes_dict["total_size_big"] = total_sizes_big
  258. total_sizes_dict_rule["total_size_small"] = total_sizes_small_rule
  259. total_sizes_dict["total_size_small"] = total_sizes_small
  260. # 上半场总分大小
  261. try:
  262. half_total_sizes = result['o']["ou1st"]["v"]
  263. half_total_sizes_big_rule,half_total_sizes_big,half_total_sizes_small_rule,half_total_sizes_small = rangqiu_daxiao(inner=half_total_sizes, pt=pt)
  264. total_sizes_dict_rule["half_total_size_big"] = half_total_sizes_big_rule
  265. total_sizes_dict["half_total_size_big"] = half_total_sizes_big
  266. total_sizes_dict_rule["half_total_size_small"] = half_total_sizes_small_rule
  267. total_sizes_dict["half_total_size_small"] = half_total_sizes_small
  268. except:
  269. half_total_sizes_big_rule = ""
  270. half_total_sizes_big = ""
  271. half_total_sizes_small_rule = ""
  272. half_total_sizes_small = ""
  273. total_sizes_dict_rule["half_total_size_big"] = half_total_sizes_big_rule
  274. total_sizes_dict["half_total_size_big"] = half_total_sizes_big
  275. total_sizes_dict_rule["half_total_size_small"] = half_total_sizes_small_rule
  276. total_sizes_dict["half_total_size_small"] = half_total_sizes_small
  277. # 第一节总分大小
  278. try:
  279. one_total_sizes = result['o']["ou1st"]["v"]
  280. one_total_sizes_big_rule,one_total_size_big,one_total_sizes_small_rule,one_total_sizes_small = rangqiu_daxiao(inner=one_total_sizes, pt=pt)
  281. total_sizes_dict_rule["one_total_size_big"] = one_total_sizes_big_rule
  282. total_sizes_dict["one_total_size_big"] = one_total_size_big
  283. total_sizes_dict_rule["one_total_size_small"] = one_total_sizes_small_rule
  284. total_sizes_dict["one_total_size_small"] = one_total_sizes_small
  285. except:
  286. one_total_sizes_big_rule = ""
  287. one_total_sizes_big = ""
  288. one_total_sizes_small_rule = ""
  289. one_total_sizes_small = ""
  290. total_sizes_dict_rule["one_total_size_big"] = one_total_sizes_big_rule
  291. total_sizes_dict["one_total_size_big"] = one_total_sizes_big
  292. total_sizes_dict_rule["one_total_size_small"] = one_total_sizes_small_rule
  293. total_sizes_dict["one_total_size_small"] = one_total_sizes_small
  294. # 第二节场总分大小
  295. try:
  296. two_total_sizes = result['o']["ou1st"]["v"]
  297. two_total_sizes_big_rule,two_total_sizes_big,two_total_sizes_small_rule,two_total_sizes_small = rangqiu_daxiao(inner=two_total_sizes, pt=pt)
  298. total_sizes_dict_rule["two_total_size_big"] = two_total_sizes_big_rule
  299. total_sizes_dict["two_total_size_big"] = two_total_sizes_big
  300. total_sizes_dict_rule["two_total_size_small"] = two_total_sizes_small_rule
  301. total_sizes_dict["two_total_size_small"] = two_total_sizes_small
  302. except:
  303. two_total_sizes_big_rule = ""
  304. two_total_sizes_big = ""
  305. two_total_sizes_small_rule = ""
  306. two_total_sizes_small = ""
  307. total_sizes_dict_rule["two_total_size_big"] = two_total_sizes_big_rule
  308. total_sizes_dict["two_total_size_big"] = two_total_sizes_big
  309. total_sizes_dict_rule["two_total_size_small"] = two_total_sizes_small_rule
  310. total_sizes_dict["two_total_size_small"] = two_total_sizes_small
  311. # 第三节总分大小
  312. try:
  313. three_total_sizes = result['o']["ou1st"]["v"]
  314. three_total_sizes_big_rule,three_total_sizes_big,three_total_sizes_small_rule,three_total_sizes_small = rangqiu_daxiao(inner=three_total_sizes, pt=pt)
  315. total_sizes_dict_rule["three_total_size_big"] = three_total_sizes_big_rule
  316. total_sizes_dict["three_total_size_big"] = three_total_sizes_big
  317. total_sizes_dict_rule["three_total_size_small"] = three_total_sizes_small_rule
  318. total_sizes_dict["three_total_size_small"] = three_total_sizes_small
  319. except:
  320. three_total_sizes_big_rule = ""
  321. three_total_sizes_big = ""
  322. three_total_sizes_small_rule = ""
  323. three_total_sizes_small = ""
  324. total_sizes_dict_rule["three_total_size_big"] = three_total_sizes_big_rule
  325. total_sizes_dict["three_total_size_big"] = three_total_sizes_big
  326. total_sizes_dict_rule["three_total_size_small"] = three_total_sizes_small_rule
  327. total_sizes_dict["three_total_size_small"] = three_total_sizes_small
  328. # 第四节总分大小
  329. try:
  330. four_total_sizes = result['o']["ou1st"]["v"]
  331. four_total_sizes_big_rule,four_total_sizes_big,four_total_sizes_small_rule,four_total_sizes_small = rangqiu_daxiao(inner=four_total_sizes, pt=pt)
  332. total_sizes_dict_rule["four_total_size_big"] = four_total_sizes_big_rule
  333. total_sizes_dict["four_total_size_big"] = four_total_sizes_big
  334. total_sizes_dict_rule["four_total_size_small"] = four_total_sizes_small_rule
  335. total_sizes_dict["four_total_size_small"] = four_total_sizes_small
  336. except:
  337. four_total_sizes_big_rule = ""
  338. four_total_sizes_big = ""
  339. four_total_sizes_small_rule = ""
  340. four_total_sizes_small = ""
  341. total_sizes_dict_rule["four_total_size_big"] = four_total_sizes_big_rule
  342. total_sizes_dict["four_total_size_big"] = four_total_sizes_big
  343. total_sizes_dict_rule["four_total_size_small"] = four_total_sizes_small_rule
  344. total_sizes_dict["four_total_size_small"] = four_total_sizes_small
  345. # ----------------------------------------总分单双分割线------------------------------------------------------------------
  346. # 全场 总分单双
  347. try:
  348. odd_evens = result['o']["oe"]["v"]
  349. # # 全场 总分单, 全场 总分双
  350. odd_even_odd, odd_even_even = danshaung_fun(inner=odd_evens)
  351. odd_evens_dict["two_sides_single"] = odd_even_odd
  352. odd_evens_dict_rule['two_sides_single'] = '单'
  353. odd_evens_dict["two_sides_double"] = odd_even_even
  354. odd_evens_dict_rule['two_sides_double'] = '双'
  355. except:
  356. odd_even_odd = ""
  357. odd_even_even = ""
  358. odd_evens_dict["two_sides_single"] = odd_even_odd
  359. odd_evens_dict_rule['two_sides_single'] = '单'
  360. odd_evens_dict["two_sides_double"] = odd_even_even
  361. odd_evens_dict_rule['two_sides_double'] = '双'
  362. # 上半场全场 总分单双
  363. try:
  364. half_odd_evens = result['o']["oe1st"]["v"]
  365. # 上半场 总分单, 上半场 总分双
  366. half_odd_even_odd,half_odd_even_even = danshaung_fun(inner=half_odd_evens)
  367. odd_evens_dict["two_sides_single"] = half_odd_even_odd
  368. odd_evens_dict_rule['two_sides_single'] = '单'
  369. odd_evens_dict["two_sides_double"] = half_odd_even_even
  370. odd_evens_dict_rule['two_sides_double'] = '双'
  371. except:
  372. half_odd_even_odd = ""
  373. half_odd_even_even = ""
  374. odd_evens_dict["half_two_sides_single"] = half_odd_even_odd
  375. odd_evens_dict_rule['half_two_sides_single'] = '单'
  376. odd_evens_dict["half_two_sides_double"] = half_odd_even_even
  377. odd_evens_dict_rule['half_two_sides_double'] = '双'
  378. # 总分:单/双-第一节
  379. try:
  380. one_odd_evens = result['o']["oeq1"]["v"]
  381. one_odd_even_odd,one_odd_even_even = danshaung_fun(inner=one_odd_evens)
  382. odd_evens_dict["one_two_sides_single"] = one_odd_even_odd
  383. odd_evens_dict_rule['one_two_sides_single'] = '单'
  384. odd_evens_dict["one_two_sides_double"] = one_odd_even_even
  385. odd_evens_dict_rule['one_two_sides_double'] = '双'
  386. except:
  387. one_odd_even_odd = ""
  388. one_odd_even_even = ""
  389. odd_evens_dict["one_two_sides_single"] = one_odd_even_odd
  390. odd_evens_dict_rule['one_two_sides_single'] = '单'
  391. odd_evens_dict["one_two_sides_double"] = one_odd_even_even
  392. odd_evens_dict_rule['one_two_sides_double'] = '双'
  393. # 总分:单/双-第二节
  394. try:
  395. two_odd_evens = result['o']["oeq2"]["v"]
  396. two_odd_even_odd,two_odd_even_even = danshaung_fun(inner=two_odd_evens)
  397. odd_evens_dict["two_two_sides_single"] = two_odd_even_odd
  398. odd_evens_dict_rule['two_two_sides_single'] = '单'
  399. odd_evens_dict["two_two_sides_double"] = two_odd_even_even
  400. odd_evens_dict_rule['two_two_sides_double'] = '双'
  401. except:
  402. two_odd_even_odd = ""
  403. two_odd_even_even = ""
  404. odd_evens_dict["two_two_sides_single"] = two_odd_even_odd
  405. odd_evens_dict_rule['two_two_sides_single'] = '单'
  406. odd_evens_dict["two_two_sides_double"] = two_odd_even_even
  407. odd_evens_dict_rule['two_two_sides_double'] = '双'
  408. # 总分:单/双-第三节
  409. try:
  410. three_odd_evens = result['o']["oeq3"]["v"]
  411. three_odd_even_odd,three_odd_even_even = danshaung_fun(inner=three_odd_evens)
  412. odd_evens_dict["three_two_sides_single"] = three_odd_even_odd
  413. odd_evens_dict_rule['three_two_sides_single'] = '单'
  414. odd_evens_dict["three_two_sides_double"] = three_odd_even_even
  415. odd_evens_dict_rule['three_two_sides_double'] = '双'
  416. except:
  417. three_odd_even_odd = ""
  418. three_odd_even_even = ""
  419. odd_evens_dict["three_two_sides_single"] = three_odd_even_odd
  420. odd_evens_dict_rule['three_two_sides_single'] = '单'
  421. odd_evens_dict["three_two_sides_double"] = three_odd_even_even
  422. odd_evens_dict_rule['three_two_sides_double'] = '双'
  423. # 总分:单/双-第四节
  424. try:
  425. four_odd_evens = result['o']["oeq4"]["v"]
  426. four_odd_even_odd,four_odd_even_even = danshaung_fun(inner=four_odd_evens)
  427. odd_evens_dict["four_two_sides_single"] = four_odd_even_odd
  428. odd_evens_dict_rule['four_two_sides_single'] = '单'
  429. odd_evens_dict["four_two_sides_double"] = four_odd_even_even
  430. odd_evens_dict_rule['four_two_sides_double'] = '双'
  431. except:
  432. four_odd_even_odd = ""
  433. four_odd_even_even = ""
  434. odd_evens_dict["four_two_sides_single"] = four_odd_even_odd
  435. odd_evens_dict_rule['four_two_sides_single'] = '单'
  436. odd_evens_dict["four_two_sides_double"] = four_odd_even_even
  437. odd_evens_dict_rule['four_two_sides_double'] = '双'
  438. # ----------------------------------------球队得分最后一位数分割线---------------------------------------------------------
  439. # 球队得分最后一位数 主队
  440. try:
  441. last_numbers = result["p-o"][0]['o']
  442. last_home = {last_numbers[0][0]: last_numbers[0][2], last_numbers[1][0]: last_numbers[1][2],
  443. last_numbers[2][0]: last_numbers[2][2], last_numbers[3][0]: last_numbers[3][2],
  444. last_numbers[4][0]: last_numbers[4][2]}
  445. # if last_numbers:
  446. # for last_number in last_numbers:
  447. # last_home[last_number[0]] = last_number[2]
  448. except:
  449. last_home = {}
  450. last_numbers_dict["last_home"] = last_home
  451. # 球队得分最后一位数 客队
  452. try:
  453. new_last_numbers = result["p-o"][1]['o']
  454. last_guest = {new_last_numbers[0][0]: new_last_numbers[0][2], new_last_numbers[1][0]: new_last_numbers[1][2],
  455. new_last_numbers[2][0]: new_last_numbers[2][2], new_last_numbers[3][0]: new_last_numbers[3][2],
  456. new_last_numbers[4][0]: new_last_numbers[4][2]}
  457. # if new_last_numbers:
  458. # for new_last_number in new_last_numbers:
  459. # last_guest[new_last_number[0]] = new_last_number[2]
  460. except:
  461. last_guest = {}
  462. last_numbers_dict["last_guest"] = last_guest
  463. # ------------------------------------------------------独赢分割线---------------------------------------------------------
  464. # 独赢
  465. try:
  466. capots = result['o']["ml"]["v"]
  467. capot_list = [capots[i] for i in range(len(capots)) if i % 2 == 1]
  468. capot_home = capot_list[0]
  469. capot_guest = capot_list[1]
  470. capots_dict["capot_home"] = capot_home
  471. capots_dict["capot_guest"] = capot_guest
  472. except:
  473. capot_home = ""
  474. capot_guest = ""
  475. capots_dict["capot_home"] = capot_home
  476. capots_dict["capot_guest"] = capot_guest
  477. # 上半场独赢
  478. try:
  479. half_capots = result['o']["ml1st"]["v"]
  480. half_capot_list = [half_capots[i] for i in range(len(half_capots)) if i % 2 == 1]
  481. half_capot_home = half_capot_list[0]
  482. half_capot_guest = half_capot_list[1]
  483. capots_dict["half_capot_home"] = half_capot_home
  484. capots_dict["half_capot_guest"] = half_capot_guest
  485. except:
  486. half_capot_home = ""
  487. half_capot_guest = ""
  488. capots_dict["half_capot_home"] = half_capot_home
  489. capots_dict["half_capot_guest"] = half_capot_guest
  490. # 第一节独赢
  491. try:
  492. one_capots = result['o']["mlq1"]["v"]
  493. one_capot_list = [one_capots[i] for i in range(len(one_capots)) if i % 2 == 1]
  494. one_capot_home = one_capot_list[0]
  495. one_capot_guest = one_capot_list[1]
  496. capots_dict["one_capot_home"] = one_capot_home
  497. capots_dict["one_capot_guest"] = one_capot_guest
  498. except:
  499. one_capot_home = ""
  500. one_capot_guest = ""
  501. capots_dict["one_capot_home"] = one_capot_home
  502. capots_dict["one_capot_guest"] = one_capot_guest
  503. # 第二节独赢
  504. try:
  505. two_capots = result['o']["mlq2"]["v"]
  506. two_capot_list = [two_capots[i] for i in range(len(two_capots)) if i % 2 == 1]
  507. two_capot_home = two_capot_list[0]
  508. two_capot_guest = two_capot_list[1]
  509. capots_dict["two_capot_home"] = two_capot_home
  510. capots_dict["two_capot_guest"] = two_capot_guest
  511. except:
  512. two_capot_home = ""
  513. two_capot_guest = ""
  514. capots_dict["two_capot_home"] = two_capot_home
  515. capots_dict["two_capot_guest"] = two_capot_guest
  516. # 第三节独赢
  517. try:
  518. three_capots = result['o']["mlq3"]["v"]
  519. three_capot_list = [three_capots[i] for i in range(len(three_capots)) if i % 2 == 1]
  520. three_capot_home = three_capot_list[0]
  521. three_capot_guest = three_capot_list[1]
  522. capots_dict["three_capot_home"] = three_capot_home
  523. capots_dict["three_capot_guest"] = three_capot_guest
  524. except:
  525. three_capot_home = ""
  526. three_capot_guest = ""
  527. capots_dict["three_capot_home"] = three_capot_home
  528. capots_dict["three_capot_guest"] = three_capot_guest
  529. # 第四节独赢
  530. try:
  531. four_capots = result['o']["mlq2"]["v"]
  532. four_capot_list = [four_capots[i] for i in range(len(four_capots)) if i % 2 == 1]
  533. four_capot_home = four_capot_list[0]
  534. four_capot_guest = four_capot_list[1]
  535. capots_dict["four_capot_home"] = four_capot_home
  536. capots_dict["four_capot_guest"] = four_capot_guest
  537. except:
  538. four_capot_home = ""
  539. four_capot_guest = ""
  540. capots_dict["four_capot_home"] = four_capot_home
  541. capots_dict["four_capot_guest"] = four_capot_guest
  542. # ---------------------------------------------------华丽分割线列表es[1]--------------------------------------------------
  543. # 球队得分 全场主队 home
  544. if result['pci']['ctid'] == 41:
  545. try:
  546. score_home = new_data[1]
  547. except:
  548. score_home = ""
  549. # print(game_id)
  550. if score_home:
  551. try:
  552. score_homes = score_home["o"]["ou"]['v']
  553. score_home_big_rule,score_home_big,score_home_small_rule,score_home_small = rangqiu_daxiao(inner=score_homes)
  554. team_scores_dict_rule["score_home_big"] = score_home_big_rule
  555. team_scores_dict["score_home_big"] = score_home_big
  556. team_scores_dict_rule["score_home_small"] = score_home_small_rule
  557. team_scores_dict["score_home_small"] = score_home_small
  558. except:
  559. score_home_small = ""
  560. score_home_small_rule = ""
  561. score_home_big_rule = ""
  562. score_home_big = ""
  563. team_scores_dict_rule["score_home_big"] = score_home_big_rule
  564. team_scores_dict["score_home_big"] = score_home_big
  565. team_scores_dict_rule["score_home_small"] = score_home_small_rule
  566. team_scores_dict["score_home_small"] = score_home_small
  567. # 球队得分 上半场主队 home
  568. try:
  569. half_score_homes = score_home['o']['ou1st']['v']
  570. # 球队得分 上半场主队 大条件
  571. half_score_home_big_rule,half_score_home_big,half_score_home_small_rule,half_score_home_small = rangqiu_daxiao(inner=half_score_homes)
  572. team_scores_dict_rule["half_score_home_big"] = half_score_home_big_rule
  573. team_scores_dict["half_score_home_big"] = half_score_home_big
  574. team_scores_dict_rule["half_score_home_small"] = half_score_home_small_rule
  575. team_scores_dict["half_score_home_small"] = half_score_home_small
  576. except:
  577. half_score_home_small = ""
  578. half_score_home_small_rule = ""
  579. half_score_home_big = ""
  580. half_score_home_big_rule = ""
  581. team_scores_dict_rule["half_score_home_big"] = half_score_home_big_rule
  582. team_scores_dict["half_score_home_big"] = half_score_home_big
  583. team_scores_dict_rule["half_score_home_small"] = half_score_home_small_rule
  584. team_scores_dict["half_score_home_small"] = half_score_home_small
  585. # 球队得分:主队-大 / 小-第一节
  586. try:
  587. one_score_homes = score_home['o']["ouq1"]["v"]
  588. one_score_home_big_rule,one_score_home_big,one_score_home_small_rule,one_score_home_small = rangqiu_daxiao(inner=one_score_homes)
  589. team_scores_dict_rule["one_score_home_big"] = one_score_home_big_rule
  590. team_scores_dict["one_score_home_big"] = one_score_home_big
  591. team_scores_dict_rule["one_score_home_small"] = one_score_home_small_rule
  592. team_scores_dict["one_score_home_small"] = one_score_home_small
  593. except:
  594. one_score_home_small = ""
  595. one_score_home_small_rule = ""
  596. one_score_home_big = ""
  597. one_score_home_big_rule = ""
  598. team_scores_dict_rule["one_score_home_big"] = one_score_home_big_rule
  599. team_scores_dict["one_score_home_big"] = one_score_home_big
  600. team_scores_dict_rule["one_score_home_small"] = one_score_home_small_rule
  601. team_scores_dict["one_score_home_small"] = one_score_home_small
  602. # 球队得分:主队-大 / 小-第一节
  603. try:
  604. two_score_homes = score_home['o']["ouq2"]["v"]
  605. two_score_home_big_rule,two_score_home_big,two_score_home_small_rule,two_score_home_small = rangqiu_daxiao(inner=two_score_homes)
  606. team_scores_dict_rule["two_score_home_big"] = two_score_home_big_rule
  607. team_scores_dict["two_score_home_big"] = two_score_home_big
  608. team_scores_dict_rule["two_score_home_small"] = two_score_home_small_rule
  609. team_scores_dict["two_score_home_small"] = two_score_home_small
  610. except:
  611. two_score_home_small = ""
  612. two_score_home_small_rule = ""
  613. two_score_home_big = ""
  614. two_score_home_big_rule = ""
  615. team_scores_dict_rule["two_score_home_big"] = two_score_home_big_rule
  616. team_scores_dict["two_score_home_big"] = two_score_home_big
  617. team_scores_dict_rule["two_score_home_small"] = two_score_home_small_rule
  618. team_scores_dict["two_score_home_small"] = two_score_home_small
  619. # 球队得分:主队-大 / 小-第一节
  620. try:
  621. three_score_homes = score_home['o']["ouq3"]["v"]
  622. three_score_home_big_rule,three_score_home_big,three_score_home_small_rule,three_score_home_small = rangqiu_daxiao(inner=three_score_homes)
  623. team_scores_dict_rule["three_score_home_big"] = three_score_home_big_rule
  624. team_scores_dict["three_score_home_big"] = three_score_home_big
  625. team_scores_dict_rule["three_score_home_small"] = three_score_home_small_rule
  626. team_scores_dict["three_score_home_small"] = three_score_home_small
  627. except:
  628. three_score_home_small = ""
  629. three_score_home_small_rule = ""
  630. three_score_home_big = ""
  631. three_score_home_big_rule = ""
  632. team_scores_dict_rule["three_score_home_big"] = three_score_home_big_rule
  633. team_scores_dict["three_score_home_big"] = three_score_home_big
  634. team_scores_dict_rule["three_score_home_small"] = three_score_home_small_rule
  635. team_scores_dict["three_score_home_small"] = three_score_home_small
  636. # 球队得分:主队-大 / 小-第四节
  637. try:
  638. four_score_homes = score_home['o']["ouq4"]["v"]
  639. four_score_home_big_rule,four_score_home_big,four_score_home_small_rule,four_score_home_small = rangqiu_daxiao(inner=four_score_homes)
  640. team_scores_dict_rule["four_score_home_big"] = four_score_home_big_rule
  641. team_scores_dict["four_score_home_big"] = four_score_home_big
  642. team_scores_dict_rule["four_score_home_small"] = four_score_home_small_rule
  643. team_scores_dict["four_score_home_small"] = four_score_home_small
  644. except:
  645. four_score_home_small = ""
  646. four_score_home_small_rule = ""
  647. four_score_home_big = ""
  648. four_score_home_big_rule = ""
  649. team_scores_dict_rule["four_score_home_big"] = four_score_home_big_rule
  650. team_scores_dict["four_score_home_big"] = four_score_home_big
  651. team_scores_dict_rule["four_score_home_small"] = four_score_home_small_rule
  652. team_scores_dict["four_score_home_small"] = four_score_home_small
  653. # ---------------------------------------------------华丽分割线列表es[2]--------------------------------------------------
  654. # 球队得分 客队 guest
  655. if result['pci']['ctid'] == 42:
  656. try:
  657. score_guest = new_data[2]
  658. except:
  659. score_guest = ""
  660. if score_guest:
  661. try:
  662. # 球队得分: 大 / 小
  663. score_guests = score_guest["o"]["ou"]['v']
  664. score_guest_big_rule,score_guest_big,score_guest_small_rule,score_guest_small = rangqiu_daxiao(inner=score_guests)
  665. team_scores_dict_rule["score_guest_big"] = score_guest_big_rule
  666. team_scores_dict["score_guest_big"] = score_guest_big
  667. team_scores_dict_rule["score_guest_small"] = score_guest_small_rule
  668. team_scores_dict["score_guest_small"] = score_guest_small
  669. except:
  670. score_guest_small = ""
  671. score_guest_small_rule = ""
  672. score_guest_big = ""
  673. score_guest_big_rule = ""
  674. team_scores_dict_rule["score_guest_big"] = score_guest_big_rule
  675. team_scores_dict["score_guest_big"] = score_guest_big
  676. team_scores_dict_rule["score_guest_small"] = score_guest_small_rule
  677. team_scores_dict["score_guest_small"] = score_guest_small
  678. # 球队得分 上半场客队 guest
  679. try:
  680. half_score_guests = score_guest["o"]['ou1st']['v']
  681. half_score_guest_big_rule,half_score_guest_big,half_score_guest_small_rule,half_score_guest_small = rangqiu_daxiao(inner=half_score_guests)
  682. team_scores_dict_rule["half_score_guest_big"] = half_score_guest_big_rule
  683. team_scores_dict["half_score_guest_big"] = half_score_guest_big
  684. team_scores_dict_rule["half_score_guest_small"] = half_score_guest_small_rule
  685. team_scores_dict["half_score_guest_small"] = half_score_guest_small
  686. except:
  687. half_score_guest_small = ""
  688. half_score_guest_small_rule = ""
  689. half_score_guest_big = ""
  690. half_score_guest_big_rule = ""
  691. team_scores_dict_rule["half_score_guest_big"] = half_score_guest_big_rule
  692. team_scores_dict["half_score_guest_big"] = half_score_guest_big
  693. team_scores_dict_rule["half_score_guest_small"] = half_score_guest_small_rule
  694. team_scores_dict["half_score_guest_small"] = half_score_guest_small
  695. # 球队得分第一节
  696. try:
  697. one_score_guests = score_guest["o"]['ouq1']['v']
  698. one_score_guest_big_rule, one_score_guest_big, one_score_guest_small_rule, one_score_guest_small = rangqiu_daxiao(
  699. inner=one_score_guests)
  700. team_scores_dict_rule["one_score_guest_big"] = one_score_guest_big_rule
  701. team_scores_dict["one_score_guest_big"] = one_score_guest_big
  702. team_scores_dict_rule["one_score_guest_small"] = one_score_guest_small_rule
  703. team_scores_dict["one_score_guest_small"] = one_score_guest_small
  704. except:
  705. one_score_guest_small = ""
  706. one_score_guest_small_rule = ""
  707. one_score_guest_big = ""
  708. one_score_guest_big_rule = ""
  709. team_scores_dict_rule["one_score_guest_big"] = one_score_guest_big_rule
  710. team_scores_dict["one_score_guest_big"] = one_score_guest_big
  711. team_scores_dict_rule["one_score_guest_small"] = one_score_guest_small_rule
  712. team_scores_dict["one_score_guest_small"] = one_score_guest_small
  713. # 球队得分第二节
  714. try:
  715. two_score_guests = score_guest["o"]['ouq2']['v']
  716. two_score_guest_big_rule, two_score_guest_big, two_score_guest_small_rule, two_score_guest_small = rangqiu_daxiao(
  717. inner=two_score_guests)
  718. team_scores_dict_rule["two_score_guest_big"] = two_score_guest_big_rule
  719. team_scores_dict["two_score_guest_big"] = two_score_guest_big
  720. team_scores_dict_rule["two_score_guest_small"] = two_score_guest_small_rule
  721. team_scores_dict["two_score_guest_small"] = two_score_guest_small
  722. except:
  723. two_score_guest_small = ""
  724. two_score_guest_small_rule = ""
  725. two_score_guest_big = ""
  726. two_score_guest_big_rule = ""
  727. team_scores_dict_rule["two_score_guest_big"] = two_score_guest_big_rule
  728. team_scores_dict["two_score_guest_big"] = two_score_guest_big
  729. team_scores_dict_rule["lq_two_score_guest_small"] = two_score_guest_small_rule
  730. team_scores_dict["two_score_guest_small"] = two_score_guest_small
  731. # 球队得分第三节
  732. try:
  733. three_score_guests = score_guest["o"]['ouq3']['v']
  734. three_score_guest_big_rule, three_score_guest_big, three_score_guest_small_rule, three_score_guest_small = rangqiu_daxiao(
  735. inner=three_score_guests)
  736. team_scores_dict_rule["three_score_guest_big"] = three_score_guest_big_rule
  737. team_scores_dict["three_score_guest_big"] = three_score_guest_big
  738. team_scores_dict_rule["three_score_guest_small"] = three_score_guest_small_rule
  739. team_scores_dict["three_score_guest_small"] = three_score_guest_small
  740. except:
  741. three_score_guest_small = ""
  742. three_score_guest_small_rule = ""
  743. three_score_guest_big = ""
  744. three_score_guest_big_rule = ""
  745. team_scores_dict_rule["three_score_guest_big"] = three_score_guest_big_rule
  746. team_scores_dict["three_score_guest_big"] = three_score_guest_big
  747. team_scores_dict_rule["three_score_guest_small"] = three_score_guest_small_rule
  748. team_scores_dict["three_score_guest_small"] = three_score_guest_small
  749. # 球队得分第四节
  750. try:
  751. four_score_guests = score_guest["o"]['ouq4']['v']
  752. four_score_guest_big_rule, four_score_guest_big, four_score_guest_small_rule, four_score_guest_small = rangqiu_daxiao(
  753. inner=four_score_guests)
  754. team_scores_dict_rule["four_score_guest_big"] = four_score_guest_big_rule
  755. team_scores_dict["four_score_guest_big"] = four_score_guest_big
  756. team_scores_dict_rule["four_score_guest_small"] = four_score_guest_small_rule
  757. team_scores_dict["four_score_guest_small"] = four_score_guest_small
  758. except:
  759. four_score_guest_small = ""
  760. four_score_guest_small_rule = ""
  761. four_score_guest_big = ""
  762. four_score_guest_big_rule = ""
  763. team_scores_dict_rule["four_score_guest_big"] = four_score_guest_big_rule
  764. team_scores_dict["four_score_guest_big"] = four_score_guest_big
  765. team_scores_dict_rule["four_score_guest_small"] = four_score_guest_small_rule
  766. team_scores_dict["four_score_guest_small"] = four_score_guest_small
  767. # 联赛id
  768. item['league_id'] = league_id
  769. # 联赛名
  770. item['league_name'] = league_name
  771. # item['result'] = result
  772. # 比赛id
  773. item['game_id'] = data[0]
  774. # 球队1
  775. item['team_home'] = data[1]
  776. # 球队2
  777. item['team_guest'] = data[2]
  778. # 数量(97>)
  779. item['number'] = data[3]
  780. # 比赛状态
  781. item['zhuangtai'] = data[4]
  782. # 日期
  783. item['data_game'] = data[5]
  784. # 开赛时间
  785. item['time_game'] = data[6]
  786. # 队1分数
  787. item['score_home'] = data[7]
  788. # 队2分数
  789. item['score_guest'] = data[8]
  790. # 第几节
  791. item['jijie'] = data[9]
  792. item['pt'] = pt
  793. # 球队得分
  794. item['qiudui'] = data[10]
  795. item['concede'] = concedes_dict
  796. item['concede_rule'] = concedes_dict_rule
  797. item['odd_even'] = odd_evens_dict
  798. item['odd_even_rule'] = odd_evens_dict_rule
  799. item['total_size'] = total_sizes_dict
  800. item['total_size_rule'] = total_sizes_dict_rule
  801. item['last_number'] = last_numbers_dict
  802. item['capot'] = capots_dict
  803. item['team_score'] = team_scores_dict
  804. item['team_score_rule'] = team_scores_dict_rule
  805. item['lanqiu'] = lanqiu
  806. yield item