roll_lanqiu.py 44 KB

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