抓取解析接口的视频真实地址(三)

关键点:python+selenium+chromedriver
1.下载python3.7
2.配置环境变量
3.pip install selenium
4.下载对应版本的chromedriver
下载地址http://chromedriver.storage.googleapis.com/index.html
抓取代码如下

from selenium import webdriver
import time
import MySQLdb
import sys
import tempfile
#sys.stderr=tempfile.TemporaryFile()
option = webdriver.ChromeOptions()
#浏览器页面不显示
# option.add_argument('headless')
#模拟手机
option.add_argument('--user-agent=iphone')
#修改platform
option.add_extension('C:\\Users\\yesia\\Desktop\\我的浏览器插件.crx')
driver = webdriver.Chrome(options=option)
#传递参数
url=sys.argv[1]
domain="这里是自己写的html的地址"
driver.get(domain+url)

由于接口不同,提供几个抓取的关键代码

driver.switch_to.frame(0)
video=driver.find_element_by_xpath("//*[@id='a1']/video")
source=driver.execute_script("return arguments[0].currentSrc;",video)
source=driver.find_element_by_name("flashvars").get_attribute("value")
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。