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?

1

1 Answer 1

1

Use request's library unquote()

import requests

requests.utils.unquote(title)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.