You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Python requests模块请求指定网站无响应且报错的问题求助

使用Python requests模块请求指定网站无响应且报错的问题求助

Hey everyone, I'm trying to send an HTTP GET request to a New York state building search website using the requests module, and I'm expecting a 200 status code in return. But no matter how many times I run my script, I keep hitting an error (the full error trace is cut off, but here's what I have). I already added browser-like headers to my request, but I still can't get a proper response.

Here's my code:

import requests

link = 'https://apps.hcr.ny.gov/BuildingSearch/'

headers = {
    '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': 'en-US,en;q=0.9',
    'host': 'apps.hcr.ny.gov',
    'origin': 'https://apps.hcr.ny.gov',
    'referer': 'https://apps.hcr.ny.gov/BuildingSearch/',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
}

with requests.Session() as s:
    s.headers.update(headers)
    res = s.get(link,headers=headers)
    print(res.status_code)

The error message I receive is:

File "C:\Users\CL\AppData\Local\P...

备注:内容来源于stack exchange,提问作者MITHU

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 11:15:30