获取英雄联盟网页
import time
import fake_useragent
import requests
from selenium import webdriver
# 英雄联盟 爬虫
# selenium
# pip install selenium
# url,request方法来请求英雄联盟网页,但是获取时会存在来不及渲染的情况,即无法显示整个页面
url = 'https://101.qq.com/'
head = {
"User-Agent": fake_useragent.UserAgent().random
}
resp = requests.get(url, headers=head)
with open("./lol.html", "w", encoding='utf-8') as fp:
fp.write(resp.text)
#解决方案,使用selenium在Edge浏览器上执行自动化测试
driver = webdriver.Edge()
driver.get('https://101.qq.com/')
#页面在十秒后关闭
time.sleep(10)
#关闭驱动
driver.close()
标签:联盟,网页,Python,selenium,driver,爬取,url,import
From: https://blog.csdn.net/m0_58050808/article/details/136951733