from selenium import webdriver
from time import sleep
from lxml import etree
from random import randint
edge = webdriver.Edge()
edge.get("https://www.huya.com/g/lol")
sleep(10)
n = 1
while True:
html = edge.page_source
e = etree.HTML(html)
names = e.xpath('''//i[@class='nick']/text()''')
counts = e.xpath('''//i[@class='js-num']/text()''')
print('-----------------------------------------------这是第{}业'.format(n))
for name,count in zip(names,counts):
print(name,':',count)
if edge.page_source.find('laypage_next')!=-1:
edge.find_element_by_class_name('laypage_next').click()
else:
break
n = n+1
sleep(randint(5,11))
(24)爬虫selenium虎牙练习
最新推荐文章于 2021-02-03 00:19:53 发布