# 1.导入模块
import requests
from lxml import etree
import xlwt
title = []
category = []
ticket = []
info = []
chapter = []
# 2.发送请求
url = 'https://www.zongheng.com/rank/details.html?rt=1&d=1&i=2'
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36'
}
# 获取列表里的文本
def get_first_name(list):
try:
return list[0].strip()
except:
return ''
urls = ['https://www.zongheng.com/rank/details.html?rt=1&d=1&i=2&p={}'.format(i) for i in range(1, 11)]
count = 1
for url in urls:
res = requests.get(url=url, headers=headers)
# print(res.status_code)
html = etree.HTML(res.text)
lis = html.xpath('//div[@class="