lanqiu.py 46 KB

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