如何为 Django 项目编写 ProxyConnetionError 异常(errno - 10060,无法连接到代理)
How to write exception for ProxyConnetionError (errno - 10060, can't connect to proxy) for a Django project
任何人都可以帮助我如何为 ProxyConnectionError 编写异常吗?浏览互联网后,我在 Django 项目中尝试了以下代码
from aiohttp_socks import ProxyConnectionError
try:
return render(request,"data.html")
except ProxyConnectionError:
return HttpResponse("{Exception: check proxy settings}")
我用下面的代码解决了这个问题
def user(request):
try:
c = twint.Config()
c.Username = "twitter"
c.Limit=20
c.Hide_output = True
c.Store_json=True
c.Proxy_host = myresult[1]
c.Proxy_port = myresult[2]
c.Proxy_type = "socks5"
asyncio.set_event_loop(asyncio.new_event_loop())
twint.run.Search(c)
return render(request,"data.html")
except ProxyConnectionError as e:
return HttpResponse(e)
任何人都可以帮助我如何为 ProxyConnectionError 编写异常吗?浏览互联网后,我在 Django 项目中尝试了以下代码
from aiohttp_socks import ProxyConnectionError
try:
return render(request,"data.html")
except ProxyConnectionError:
return HttpResponse("{Exception: check proxy settings}")
我用下面的代码解决了这个问题
def user(request):
try:
c = twint.Config()
c.Username = "twitter"
c.Limit=20
c.Hide_output = True
c.Store_json=True
c.Proxy_host = myresult[1]
c.Proxy_port = myresult[2]
c.Proxy_type = "socks5"
asyncio.set_event_loop(asyncio.new_event_loop())
twint.run.Search(c)
return render(request,"data.html")
except ProxyConnectionError as e:
return HttpResponse(e)