执行网站DOM的javascript时出现问题

2024-10-04 09:29:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用python和selenium驱动程序在执行javascript后从网页获取HTML代码。 此代码仅在我打开Chrome或firefox上的开发人员工具时出现,我需要的html代码是:

var player = new Clappr.Player({
source: "http://23.237.94.50:80/livestream/latina.m3u8? 
token=Vc8SZhwXftlW0RVBmQhpIQ&expires=1557301102",

我怀疑编写所需html代码的javascript代码是: http://cablegratis.tv/js/bye.js

我的代码在js执行之后没有得到完整的网页HTML,但是它可以与另一个带有javascript的网页一起工作

我的代码:

from selenium import webdriver
browser = webdriver.Firefox()
browser.get("http://cablegratis.tv/canal-en-vivo/fox-sports")
html_source = browser.page_source
print(html_source)

谢谢你的帮助。你知道吗


Tags: 代码browserhttp网页sourcehtmlselenium驱动程序