lanqiu.py 49 KB

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