SHARE
TWEET

Untitled

a guest Jun 16th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. res = s.get("https://www.totalcorner.com/match/live-stats/81165183")
  2. source = str(res.content)
  3.  
  4. h_goals = []
  5. a_goals = []
  6. h_goals_fixed = []
  7. a_goals_fixed = []
  8.  
  9. split_source = source.split(";")
  10.  
  11. for x in split_source:
  12.  
  13.     if "var off_home = [[" in x:
  14.         off_home = x.strip().split("$")[0].replace("var off_home = ", "").replace('\\n', "")
  15.         off_home = ast.literal_eval(off_home)
  16.  
  17.     if "var off_away = [[" in x:
  18.         off_away = x.strip().split("$")[0].replace("var off_away = ", "").replace('\\n', "")
  19.         off_away = ast.literal_eval(off_away)
  20.         #print(off_away)
  21.  
  22.     if "var on_home = [[" in x:
  23.         on_home = x.strip().split("$")[0].replace("var on_home = ", "").replace('\\n', "")
  24.         on_home = ast.literal_eval(on_home)
  25.  
  26.     if "var on_away = [[" in x:
  27.         on_away = x.strip().split("$")[0].replace("var on_away = ", "").replace('\\n', "")
  28.         on_away = ast.literal_eval(on_away)
  29.  
  30.     if "var all_attack = [[" in x:
  31.         all_attack = x.strip().split("$")[0].replace("var all_attack = ", "").replace('\\n', "")
  32.         all_attack = ast.literal_eval(all_attack)
  33.  
  34.         for x in all_attack:
  35.             if "goal_h20" in str(x):
  36.                 h_goals.append((x["x"]))
  37.             if "goal_a20" in str(x):
  38.                 a_goals.append(x["x"])
  39.  
  40.         for g in h_goals:
  41.             x = np.array([x[0] for x in on_home])
  42.             index = (np.abs(x-g)).argmin()
  43.             h_goals_fixed.append(x[index])
  44.  
  45.         for g in a_goals:
  46.             x = np.array([x[0] for x in on_away])
  47.             index = (np.abs(x-g)).argmin()
  48.             a_goals_fixed.append(x[index])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top