pythonpython-3.xhttpstransifex

Python 3 how to retrieve Transifex dashboard page


I'm a Transifex user, I need to retrieve my dashboard page with the list of all the projects of my organization. that is, the page I see when I login: https://www.transifex.com/organization/(my_organization_name)/dashboard

I can access Transifex API with this code:

import urllib.request as url

usr = 'myusername'
pwd = 'mypassword'

def GetUrl(Tx_url):
    auth_handler = url.HTTPBasicAuthHandler()
    auth_handler.add_password(realm='Transifex API',
                          uri=Tx_url,
                          user=usr,
                          passwd=pwd)
    opener = url.build_opener(auth_handler)
    url.install_opener(opener)
    f = url.urlopen(Tx_url)
    return f.read().decode("utf-8")

everything is ok, but there's no API call to get all the projects of my organization. the only way is to get that page html, and parse it, but if I use this code, I get the login page.

This works ok with google.com, but I get an error with www.transifex.com or www.transifex.com/organization/(my_organization_name)/dashboard

Python, HTTPS GET with basic authentication

I'm new at Python, I need some code with Python 3 and only standard library.

Thanks for any help.


Solution

  • The call to

    /projects/

    returns your projects along with all the public projects that you can have access (like what you said). You can search for the ones that you need by modifying the call to something like:

    https://www.transifex.com/api/2/projects/?start=1&end=6

    Doing so the number of projects returned will be restricted.

    For now maybe it would be more convenient to you, if you don't have many projects, to use this call:

    /project/project_slug

    and fetch each one separately.