Created
March 16, 2018 16:02
-
-
Save lanfon72/1c7a9b1a0710c56b0dad866cb22e67cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
def main(url, path="chromedriver.exe"): | |
chrome_options = Options() | |
chrome_options.add_argument("--headless") # uncomment for headless | |
driver = webdriver.Chrome(path, chrome_options=chrome_options) | |
driver.get(url) | |
wait = True | |
while wait: | |
cond = driver.execute_script("return jQuery('video>source').length") | |
if cond: | |
# stop autoplay | |
driver.execute_script("jQuery('button.u_rmc_btn_play').click()") | |
break | |
time.sleep(0.3) | |
# get m3u8 | |
data = driver.execute_script("return jQuery('video>source').attr('src')") | |
driver.close() | |
return data | |
if __name__ == '__main__': | |
url = r"https://tv.line.me/v/2802777_大家說英語-i-水無所不在-i-20180316/list/195074" | |
data = main(url) | |
print("m3u8 url:", data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment