lanqiu.py 50 KB

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