World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
Download our e-book of Introduction To Python
4.5 (1,292 Ratings)
559 Learners
Neha Kumawat
a year ago
from urllib3 import HTTPConnectionPool
pool = HTTPConnectionPool('ajax.googleapis.com', maxsize=1)
r = pool.request('GET', '/ajax/services/search/web',
fields={'q': 'python', 'v': '1.0'})
print 'Response Status:', r.status
# Header of the response
print 'Header: ',r.headers['content-type']
# Content of the response
print 'Python: ',len(r.data)
r = pool.request('GET', '/ajax/services/search/web',
fields={'q': 'php', 'v': '1.0'})
# Content of the response
print 'php: ',len(r.data)
print 'Number of Connections: ',pool.num_connections
print 'Number of requests: ',pool.num_requests
Response Status: 200
Header: text/javascript; charset=utf-8
Python: 211
php: 211
Number of Connections: 1
Number of requests: 2