roll_lanqiu.py 39 KB

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