Python请求在此特定网站上仍禁止出现错误403

2024-09-27 21:23:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从印度尼西亚证券交易所网站上删除股票符号列表。但我仍然有403错误,尽管我已经尝试修改请求的头(这是很多人建议的)

我没有web管理安全方面的专业知识,所以我想问的是,由于服务器端的某种保护,这项任务仍然可行还是死路一条?下面是我的代码。谢谢

import requests

url = 'https://www.idx.co.id/data-pasar/data-saham/daftar-saham/'
hdr = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11',
       'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
       'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
       'Accept-Encoding': 'none',
       'Accept-Language': 'en-US,en;q=0.8',
       'Connection': 'keep-alive'}

session = requests.Session()
response = session.get(url, headers=hdr)

print(response.status_code)

Tags: urldatahdrapplication网站responsesession符号

热门问题