无法通过Python访问cowin api

2024-09-29 00:11:47 发布

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

我有以下代码要在Pythonywhere上运行,在flask应用程序中

import requests

headers = {                                                                                                                                               
    'Host': 'cdn-api.co-vin.in',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36'
}

url = "https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=360311&date=15-05-2021"

response = requests.request("GET", url, headers=headers, data={})

它在部署时给了我以下错误

<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>403 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Request blocked.
We cant connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the
 app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentati
on.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: T8CDbBTWmri-1gJ4CIEASotEbtHQjGflb-rCmBASEt1ojwC3R9FN_Q==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>

这在本地主机上正常工作,但在部署时会出现上述错误。请建议是否有任何反向代理或其他部署方式


Tags: orthetoinapirequest部署cdn
2条回答

您可以在Cowin Open Tracker on GitHub上检查已关闭的问题

发行编号#183^{}

https://github.com/cowinapi/developer.cowin/issues/183

有关更多问题,请访问GitHub上的Open Tracker。如果您的查询未基于已解决的问题得到解决,您甚至可以提出新问题

印度以外的IP被Cowin服务器阻止,如果使用Heroku部署,则其默认区域为US,因此,请尝试使用AWS并选择亚太(孟买)区域

希望这能奏效

相关问题 更多 >