1.直接上代码吧

import requests,re
from requests.packages.urllib3.exceptions import InsecureRequestWarning
# 禁用安全请求警告
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

# TODO http://www.tjconstruct.cn/Zbgg/Index/1?type=sgzb

url = 'http://www.tjconstruct.cn/Zbgg/Index/1?type=sgzb'
headers = { 
    'Host': 'www.tjconstruct.cn',
    'Connection': 'keep-alive',
    'Upgrade-Insecure-Requests': '1',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
    '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.9',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cookie': 'ASP.NET_SessionId=pvcjnu2qlrigx2gvjwk5roa1',
}
r = requests.get(url=url,headers=headers).text

for i in re.findall('http://218.67.246.198:8089/shchxt/tonggao.doc(.*?)"', r, re.S):
    link = 'http://218.67.246.198:8089/shchxt/tonggao.doc'+i

    rr = requests.get(url=link, headers=headers)
    print(rr.encoding) # TODO 查看编码

    res_obj = requests.get(url=link,headers=headers).text
    print(res_obj.encode("iso-8859-1").decode('gbk'))
    break

本文地址:https://blog.csdn.net/shoujut/article/details/110876164