Skip to main content
ertius.org

Custom User Agent With Twisted Web Client GetPage

Since getPage just passes most of its’ args through to HTTPClientFactory, you can just make a simple wrapper to set the user-agent:

from twisted.web.client import getPage
...
def my_page_getter(*args, **kwargs):
    if 'agent' not in kwargs:
        kwargs['agent'] = 'your user agent/1.2'
    return getPage(*args, **kwargs)