I'm trying to remove with Python (Not C#, PHP or others) the %20 symbol from a url after having transformed it into a string. However the symbol keeps staying unchanged no matter what formatting I tried.
here is the code I tried:
url = 'https://www.amazon.com/s?k=hbb%20magic%20dress' # Type string
title_text_data_file = url.split('=')[1]
if '%20'in title_text_data_file:
title_text_data_file = title_text_data_file.replace('%20+', '')
keyword = title_text_data_file.replace('+', ' ')
title_text_data_file = title_text_data_file + ".txt"
print('Keyword:',keyword,'- File title:',title_text_data_file,'- URL:',url)
Here is what I get:
Keyword: hbb%20magic%20dress - File title: hbb%20magic%20dress.txt - URL: https://www.amazon.com/s?k=hbb%20magic%20dress
Here is what I would like to get:
Keyword: hbb magic dress - File title: hbb+magic+dress.txt - URL: https://www.amazon.com/s?k=hbb%20magic%20dress