siznax/wptools

Use from behind a proxy that requires an authentication ?

nsebban opened this issue · 3 comments

Hello,

I read in the docs that I can configure wptools so it uses a proxy for HTTP request, but I can't seem to make it work with a proxy that requires an authentication.

I have been using the "http://:@host:port" syntax, but it doesn't take the user/pass into account. Is there a way to make it work ?

Thanks in advance.

Thanks for trying wptools, @nsebban!

I'll look into providing support for proxy auth with pycurl. We haven't tried that yet!

I've added the option to supply proxy auth parameters as a dict:

>>> help(wptools.request.WPToolsRequest.curl_setup)
Help on method curl_setup in module wptools.request:

curl_setup(self, proxy=None, timeout=0) unbound wptools.request.WPToolsRequest method
    Set curl options
    - http://pycurl.io/docs/latest/
    - https://curl.haxx.se/libcurl/c/curl_easy_setopt.html

    Proxy options (str or dict):
      proxy = 'https://example.com:80'  # pycurl.PROXY
      proxy = {
        'PROXY':   <str> host,      # pycurl.PROXY
        'PORT':    <int> port,      # pycurl.PROXYPORT
        'USERPWD': <str> user:pwd,  # pycurl.PROXYUSERPWD
      }

For example:

import wptools
proxy = {'PROXY': 'http://example.com', 'PORT': 80, 'USERPWD': 'user:password'}
page = wptools.page('Main_Page')
page.get_query(proxy=proxy)

@nsebban please try these options and let us know if they work for you.

There are more options we can try as well.

This fix was released with v0.4.17.