0

I am working on a vps server and i am runing django on iis server. I have a view which receives a link from user and crawl the website and return some information to user. I have a module which handle request stuffs and just import that in my view which i call it with the user link. I also check the request module directly, and it works fine. The problem is that when i try the procedure through django view as a user i got the following error:

    ProxyError at /gathering
HTTPConnectionPool(host='127.0.0.1', port=62341): Max retries exceeded with url: http://www.sid.ir/ (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.HTTPConnection object at 0x0000021D6FF53EE0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it')))

From request module:

 html_doc = requests.get('http://www.sid.ir').text 

Actually, my problem can be down to using requests module inside django views, As i tried with just the above code inside a view function and again the same problem.

keramat
  • 4,328
  • 6
  • 25
  • 38

1 Answers1

1

Try to add the proxies in your code:

 html_doc=requests.get('http://www.test.com', proxies={'http':'','https':''}).text
Jalpa Panchal
  • 8,251
  • 1
  • 11
  • 26
  • What are the values for proxies? We have not set any proxy on our server. – keramat Aug 10 '20 at 06:43
  • @keramat just simply add this in your code proxies={'http':'','https':''} – Jalpa Panchal Aug 10 '20 at 06:45
  • Ok, Thanks, i will check it as it is on another server which i am no connected to right now. But can you explain about what these empty values do? – keramat Aug 10 '20 at 06:48
  • @keramat https://stackoverflow.com/questions/39020011/using-pythons-requests-lib-throwing-proxyerror – Jalpa Panchal Aug 10 '20 at 08:10
  • i need to use a proxy with request in another application.The problem is that it works fine in direct usage, but connection error through django. Have you any idea? – keramat Aug 26 '20 at 14:40
  • @keramat look like the issue is related Django – Jalpa Panchal Aug 27 '20 at 08:10
  • as much as i investigated it's related to web.config. – keramat Aug 27 '20 at 09:48
  • 1
    @keramat could you share how you set proxy and what error you are getting? if possible creat new thread for new issue – Jalpa Panchal Aug 27 '20 at 09:49
  • a lot of thanks for your response. Actually i am afraid of making a lot of questions due to having not answered questions, and you know about stack policy. But, i just changed the ground of game and successfully did my work by the selenium itself. As it was ok with opening the pages with whole tunnel proxy. According to this answer: https://stackoverflow.com/a/56255678/7281675. – keramat Aug 27 '20 at 10:40