0

Hi i was wondering if I can get a python script to stay on the asked webpage for a couple of seconds before closing the connection with the webpage that's what i tried but it disconnects as soon as the respond comes in

import urllib3

http = urllib3.PoolManager()
r = http.request('GET', 'http://example.com/')
i = 0
while i <= 300 :
    i = i + 1
    time.sleep(7)
    print (i);
    time.sleep(3)
    if i == 300 :
        break
feswy
  • 1
  • 2
  • The connection is handled within the `request` execution in `r = http.request('GET', 'http://example.com/')` so when the while is executed, the http connection is already closed. What are you trying to achieve? You want to parse the HTML presented in the page? – jlnabais Oct 02 '15 at 09:28
  • im trying to get the connection to stay a couple of seconds before it closes – feswy Oct 02 '15 at 10:15
  • Take a look at this [answer](http://stackoverflow.com/questions/1037406/python-urllib2-with-keep-alive). – jlnabais Oct 02 '15 at 10:18
  • thank you for the answer but any chance it can be in urllib3? – feswy Oct 02 '15 at 19:54

0 Answers0