Python 3 detects specific URLs in variables in javascript

Asked 2 years ago, Updated 2 years ago, 143 views

I use python3.
I scraped a web page, and the variable in javascript has a URL of m3u8.
I would like to extract that variable.

I found an article saying that I should use Selenium or BeautifulSoup, but I don't know which variable it is in, and if possible, I would like to search by m3u8 string.

Please let me know if you know.

[Additional]
I moved chromedriver via selenium

driver=webdriver.Chrome(chrome_driver_path, chrome_options=chrome_options)
target_url = "http://<some domain >"
driver.get(target_url)

In , the web page can be retrieved and javascript works, but I don't know how to extract m3u8 based on the variables that javascript obtains.
If you know, please let me know.

python python3 web-scraping

2022-09-30 21:29

1 Answers

Is it like this?

import re
import requests
url='
r=requests.get(url)
m=re.search('http.*?\.m3u8', r.text)
if is not None:
    print('m3u8 URL is ',m.group(0))


2022-09-30 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.