lanqiu.py 45 KB

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