Python not concatenating string and unicode to link
Question: When I append a Unicode string to the end of str, I can not click on the URL.

Bad:

    
    
    base_url = 'https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xml&titles='
    
    url = base_url + u"Ángel_Garasa"
    print url
    

[![The final output for a name with
accents](http://i.stack.imgur.com/tkSrv.png)](http://i.stack.imgur.com/tkSrv.png)

Good:

    
    
    base_url = 'https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xml&titles='
    
    url = base_url + u"Toby_Maquire"
    print url
    

[![The final output for a name without
accents](http://i.stack.imgur.com/zNvc2.png)](http://i.stack.imgur.com/zNvc2.png)


Answer: It appears that you're printing the results in an IDE, perhaps PyCharm. You
need to percent encode a UTF-8 encoded version of the string:

    
    
    import urllib
    
    base_url = 'https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=xml&titles='
    name = u"Ángel_Garasa"
    
    print base_url + urllib.quote(name.encode("utf-8"))
    

This shows: [![image showing clickable link with percent encoded
portion](http://i.stack.imgur.com/vqie9.png)](http://i.stack.imgur.com/vqie9.png)

In your case you need to update your code, so that the relevant field from the
database is percent encoded. You only need to encode this one field to UTF-8
just for the percent encoding.

