hg3535_lanqiu.py 44 KB

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