py福利图网址获取

发布时间 2023-12-17 11:48:42作者: 萧海~

在这里插入图片描述

import requests
from lxml import etree
cookies = {
    '__51cke__': '',
    '_gid': 'GA1.2.1082932432.1702784419',
    '_gat_gtag_UA_198130079_67': '1',
    '__tins__21482327': '%7B%22sid%22%3A%201702784418035%2C%20%22vd%22%3A%202%2C%20%22expires%22%3A%201702786241890%7D',
    '__51laig__': '2',
    '_ga': 'GA1.1.1789013470.1702784419',
    '_ga_NXLL959MDB': 'GS1.1.1702784419.1.1.1702784448.0.0.0',
}

headers = {
    'authority': 'fulitu.me',
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cache-control': 'no-cache',
    # Requests sorts cookies= alphabetically
    # 'cookie': '__51cke__=; _gid=GA1.2.1082932432.1702784419; _gat_gtag_UA_198130079_67=1; __tins__21482327=%7B%22sid%22%3A%201702784418035%2C%20%22vd%22%3A%202%2C%20%22expires%22%3A%201702786241890%7D; __51laig__=2; _ga=GA1.1.1789013470.1702784419; _ga_NXLL959MDB=GS1.1.1702784419.1.1.1702784448.0.0.0',
    'pragma': 'no-cache',
    'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'document',
    'sec-fetch-mode': 'navigate',
    'sec-fetch-site': 'same-origin',
    'sec-fetch-user': '?1',
    'upgrade-insecure-requests': '1',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
}

response = requests.get('https://fulitu.me/index/2.html', cookies=cookies, headers=headers)
# print(response.text)



html=etree.HTML(response.text)
res=html.xpath('//li[@class="i_list list_n2"]/a/@href')
res_new=['https://fulitu.me'+item for item in res]
print(res_new)