Created
December 4, 2019 06:28
-
-
Save lizhaode/c841fec33f881843af1938557f85ef9e to your computer and use it in GitHub Desktop.
python exec js
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
from bs4 import BeautifulSoup | |
import js2py | |
soup = BeautifulSoup(open('test.html'),'lxml') | |
div = soup.find(name='div',attrs={'class':'premiumShowTemplate'}) | |
js_content = div.script.string.split('loadScriptUniqueId')[0] | |
aaa = 'function f(){'+js_content+'if (quality_1080p !== undefined) {return quality_1080p;} else {return quality_720p;}}' | |
f = js2py.eval_js(aaa) | |
result = f() | |
if result is not None: | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment