爬虫训练之:xpath解析的使用-爬取活动信息并存储(单线程)

只做练习,不做他用!

import re
import threading
import requests
import random
from lxml import etree
from fake_useragent import UserAgent

UA=['Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36']
headers={'user-agent':random.choice(UA)}

def get_infor(n):
    url=f'https://www.nyato.com/manzhan/?type=expired&p={n}'
    resp=requests.get(url,headers=headers).text
    #获取详情页url
    all_url1=re.compile('