Two Python classes for a web crawler
Class design

A good class in general is one that corresponds to an Abstract Data Type,
which is a collection of data and operations that work on that data.
A good ADT should have a single, clear responsibility.

The Global class is not a good ADT:


It does two unrelated things:

Contain configuration information
Manage a proxy pool

Possibly as a consequence of the previous point, it is poorly named


It would be better to split this class into two:


Configuration or Config: contain configuration information
ProxyPoolManager: manage a proxy pool


Note that ProxyPoolManager should not reference Configuration directly:
it will be best to pass to it the proxyHost and proxy as constructor parameters.

As the poorly named Conn class already does half of the proxy pool management,
it would be better to rename it to ProxyPoolManager and move getPool method into it and rename Global to Configuration.

Coding style

You have several coding style violations, not conforming to PEP8:


Use spaces around = in variable assignments, for example:

proxy = True instead of proxy=True
opts = AttrDict(...) instead of opts=AttrDict(...)

No need to put parentheses in if(self.proxy):
There should be one blank line in front of method definitions of a class: put a blank line in front of get and switch methods in the Conn class
You mistyped switch as swith


Other issues

This code doesn't compile:


class Conn:
    def get(url, opts=Global.opts):
        try:
          self.pool.urlopen(...)



Because it makes a reference to self which was not passed in as method parameter.



This is a bit hard to understand,
because of reusing the name "proxy" both as method parameter and as attribute:


def getPool(self,proxy=None):
    if proxy is  None:
        proxy = self.proxy
    if(self.proxy):
        http_pool = urllib3.proxy_from_url(self.proxyHost)
    else:
        http_pool = urllib3.connection_from_url(self.host)
    return http_pool



The purpose of this method would be more clear if you used a different name for the method parameter.