title: Use the requests in python to request a url error？
body: <p>Use the requests in python to request a url error
  The code</p>
  <pre><code>import re
  import requests
  import json
  from bs4 import BeautifulSoup
  import pymysql
  import time, datetime
  import os
  
  from requests.adapters import HTTPAdapter
  
  
  def get_random_proxy():
      proxypool_url = 'http://127.0.0.1:5555/random'
      &quot;&quot;&quot;
      get random proxy from proxypool
      :return: proxy
      &quot;&quot;&quot;
      return requests.get(proxypool_url).text.strip()
  
  
  headers = {
      'User-Agent': 'Chrome',
      'Referer': 'http://www.nmpa.gov.cn/datasearch/home-index.html?79QlcAyHig6m=1636513393895',
      'Host': 'nmpa.gov.cn',
      'Origin': 'http://nmpa.gov.cn',
      'Content-Type': 'application/x-www-form-urlencoded',
      'Connection': 'close'
  }
  url = 'https://www.nmpa.gov.cn/datasearch/search-result.html'
  
  
  def start_requests(coo):
      # r = json.loads(r.text)
      headers['Set-Cookie'] = coo
      s = requests.get(url=url, headers=headers, stream=True, timeout=(5, 5), verify=False)
      s.encoding = 'utf8'
      print(s.status_code)
      print(s)
  
  
  while True:
      proxy = {'http': 'http://' + get_random_proxy(), 'https': 'https://' + get_random_proxy()}
      print(proxy)
      try:
          sess = requests.Session()
          sess.keep_alive = False  # 关闭多余连接
          res = sess.get(url='http://nmpa.gov.cn', headers={'User-Agent': 'Chrome'}, proxies=proxy, timeout=10,
                         verify=False)
          res.close()
          print(res.status_code)
          res.encoding = 'utf8'
          cookie = res.headers['Set-Cookie']
          print(cookie)
          if res.status_code == 200:
              print(res.status_code)
              time.sleep(10)
              start_requests(cookie)
              break
      except Exception as error:
          time.sleep(10)
          print(&quot;没有连接成功&quot;, error)
  </code></pre>
  <blockquote>
  <p>{'http': 'http://178.88.185.2:3128', 'https':
  'https://58.27.253.211:8080'} 没有连接成功
  HTTPConnectionPool(host='178.88.185.2', port=3128): Max retries
  exceeded with url: <a href="http://nmpa.gov.cn/" rel="nofollow noreferrer">http://nmpa.gov.cn/</a> (Caused by ProxyError('Cannot
  connect to proxy.',
  NewConnectionError('&lt;urllib3.connection.HTTPConnection object at
  0x7f061b693f70&gt;: Failed to establish a new connection: [Errno 111]
  Connection refused'))) {'http': 'http://103.130.242.218:63123',
  'https': 'https://178.238.236.233:3128'} 没有连接成功
  HTTPConnectionPool(host='103.130.242.218', port=63123): Max retries
  exceeded with url: <a href="http://nmpa.gov.cn/" rel="nofollow noreferrer">http://nmpa.gov.cn/</a> (Caused by
  ConnectTimeoutError(&lt;urllib3.connection.HTTPConnection object at
  0x7f061b6c0130&gt;, 'Connection to 103.130.242.218 timed out. (connect
  timeout=10)')) {'http': 'http://143.0.226.116:80', 'https':
  'https://177.124.184.52:8080'} 没有连接成功
  HTTPConnectionPool(host='143.0.226.116', port=80): Max retries
  exceeded with url: <a href="http://nmpa.gov.cn/" rel="nofollow noreferrer">http://nmpa.gov.cn/</a> (Caused by
  ConnectTimeoutError(&lt;urllib3.connection.HTTPConnection object at
  0x7f061b693ca0&gt;, 'Connection to 143.0.226.116 timed out. (connect
  timeout=10)'))</p>
  </blockquote>