The image is from https://www.iijmio.jp/thissite/version
-Download from here.
--The downloaded one is in .zip format, so please put the extracted one in the executable format in your directory.
pip install beautifulsoup4 selenium requests
gpx.py
import os
import re
import sys
import time
from bs4 import BeautifulSoup
import requests
from glob import glob
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
driver = webdriver.Chrome(os.path.join(os.getcwd(), "chromedriver"))
def get_gpx_names():
return glob('*.gpx')
def upload_gpx_to_strava(gpx_names):
for i, gpx_name in enumerate(gpx_names):
driver.get('https://labs.strava.com/gpx-to-route/#12/-122.44503/37.73651')
driver.find_element_by_id("gpxFile").send_keys(os.path.join(os.getcwd(), gpx_name))
time.sleep(15)
if i == 0:
driver.find_element_by_id("oauthButton").click()
driver.switch_to.window(driver.window_handles[-1])
driver.find_element_by_id("email").send_keys("mail address")
driver.find_element_by_id("password").send_keys("password")
login_button = driver.find_element_by_id("login-button")
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
login_button.click()
time.sleep(5)
driver.switch_to.window(driver.window_handles[-1])
driver.find_element_by_id("saveButton").click()
time.sleep(5)
driver.find_element_by_class_name("save-route").click()
driver.find_element_by_id("name").send_keys("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"+os.path.splitext(os.path.basename(gpx_name))[0])
driver.find_element_by_class_name("reverse").click()
time.sleep(5)
if __name__ == "__main__":
gpx_names = get_gpx_names()
upload_gpx_to_strava(gpx_names)
python gpx.py
Recommended Posts