0

Here is my code:

import requests
import json

r = requests.get(url="news_api_here")
json_data = json.loads(r.content)

for i in range(len(json_data)):
    title = str(json_data[i]["headline"])
    print(title)

The output for a given title is something like this:

Development%2c Expansion%2c Merger%2c Acquisition%2c New Product Launches%2c and Pricing Analysis%3c%2fa%3e%3c

How can I decode the string to proper characters?

  • 2
    Does this answer your question? [Url decode UTF-8 in Python](https://stackoverflow.com/questions/16566069/url-decode-utf-8-in-python) – Mike Scotty Mar 18 '21 at 16:46

1 Answers1

1

Use request's library unquote()

import requests

requests.utils.unquote(title)

def_init_
  • 337
  • 3
  • 10