title: Scrapy : How to write a HttpProxyMiddleware?
body: <p>The docs of <code>Scrapy</code> says about <code>HttpProxyMiddleware</code> is like this:</p>
  
  <blockquote>
    <p>This middleware sets the HTTP <code>proxy</code> to use for requests, by setting the <code>proxy</code> meta value for <code>Request</code> objects.</p>
    
    <p>Like the Python standard library modules <code>urllib</code> and <code>urllib2</code>, it obeys the following environment variables:</p>
  
  <pre><code>http_proxy
  https_proxy
  no_proxy
  </code></pre>
    
    <p>You can also set the meta key proxy per-request, to a value like <code>http://some_proxy_server:port</code> or <code>http://username:password@some_proxy_server:port</code>. Keep in mind this value will take precedence over <code>http_proxy/https_proxy</code> environment variables, and it will also ignore <code>no_proxy</code> environment variable.</p>
  </blockquote>
  
  <p>docs:<a href="https://doc.scrapy.org/en/latest/topics/downloader-middleware.html?highlight=Proxy#module-scrapy.downloadermiddlewares.httpproxy" rel="nofollow noreferrer">https://doc.scrapy.org/en/latest/topics/downloader-middleware.html?highlight=Proxy#module-scrapy.downloadermiddlewares.httpproxy</a></p>
  
  <p>But there are no examples in the docs.<br>
  I have no ideas how to write a <code>HttpProxyMiddleware</code>.<br>
  Are there any suggestions?</p>