时间:2023-03-08 12:02:15 | 栏目:Python代码 | 点击:次
2.程序代码
程序代码如下:
import re from selenium import webdriver # url="https://www.ixigua.com/6982149651281478152?logTag=cc6bf98fd0f8fe35fe0e" url=input("输入视频链接:") group_id=re.findall('https://www.ixigua.com/(.*)\?logTag=.*',url) url='https://www.ixigua.com/embed?group_id='+group_id[0] # 进入浏览器设置 options = webdriver.ChromeOptions() # 设置中文 options.add_argument('lang=zh_CN.UTF-8') # 更换头部 options.add_argument('user-agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"') driver=webdriver.Chrome(options=options) driver.get(url=url) driver.implicitly_wait(5) infos=driver.find_elements_by_xpath("//xg-definition/ul/li") for info in infos[:-1]: print(info.get_attribute("definition")) print('http:'+info.get_attribute("url"))
Python爬虫下载西瓜视频