Strava, You Are Not Helping Me!

in EXHAUST11 days ago

Thanks for all your patience.

S2HLogo.png

If you haven't noticed, all your screen shots of your @strava2hive activity, has had a really nice black dialog box over the top it.

Something like this image below
image_16458802259_withCookies.png

Strava does this every six months or so and I think the developer that makes this change is completely different from the last, so I need to start from scratch to work out where I need to change or address the issue.

For anyone really interested, I use selenium to bring up the activities and then click the dialog box to accept cookies, before taking a screenshot of your activity. The code looks like this:

  s = Service('/bin/chromedriver')
  driver = webdriver.Chrome(service=s)  
  driver.get(activity_url)
  time.sleep(1)
  if driver.find_elements("xpath", "/html/body/div[1]/div/div[4]/div[1]/div/div[2]/button[4]"):
    print("Element exists!")
    driver.find_element("xpath", "/html/body/div[1]/div/div[4]/div[1]/div/div[2]/button[4]").click()
  driver.get_screenshot_as_file(image_name)
  driver.quit()

So I have been updating the full xpath to the cookies dialog box, which changes every 6 months or so. In the most recent example, it was "/html/body/div[1]/div/div[4]/div[1]/div/div[2]/button[4]". I tried that this time, so instead opted for the ID of the element of the button, like in the code below:

  s = Service('/bin/chromedriver')
  driver = webdriver.Chrome(service=s)  
  driver.get(activity_url)
  time.sleep(1)
  if driver.find_element(By.ID, "CybotCookiebotDialogBodyLevelButtonAccept"):
    driver.find_element(By.ID, "CybotCookiebotDialogBodyLevelButtonAccept").click()
    time.sleep(1)
  driver.get_screenshot_as_file(image_name)
  driver.quit()

This seems to have worked and is looking better at the moment:
image_16458802259.png

Thanks for your patience and hopefully I don't need to make any further changes for now...Maybe I need to actually do a bit more work on making the screenshots more dynamic?

Sort:  

Thanks for all your efforts, you are doing a great job for the runners community here

I know these companies change their code all the time, so it must be frustrating. They ought to provide API functions to get things like a map view. Thanks for all your hard work.

Thank for your work on this. I like the map view...