I think urljoin might be useful for the above code, rather than manually constructing a URL by concatenating strings.