python import concurrent.futures import httplib2 urls = ['http://example.com', 'http://example.org', 'http://example.net'] def fetch_url(url): http = httplib2.Http() response, content = http.request(url) return content with concurrent.futures.ThreadPoolExecutor() as executor: results = list(executor.map(fetch_url, urls)) for result in results: print(result) python import httplib2 http = httplib2.Http() http.disable_ssl_certificate_validation = True http.follow_redirects = False http.force_exception_to_status_code = True http.timeout = 10 http.default_headers['Connection'] = 'keep-alive' response, content = http.request('http://example.com') print(content) python import httplib2 http = httplib2.Http('/path/to/cache/directory') response, content = http.request('http://example.com') print(content)


上一篇:
下一篇:
切换中文