Python Beautifulsoup doubt

Asked

Viewed 41 times

0

I am making a requests.post and it returns me the following information:

{"Name":"Joey Triibianni","Vocation":"Knight","Level":"425","World":"Quelibra","Account Status:":"Free Account"}

I’ve tried some ways but I’m not able to do block formatting. I only wanted the values World : {value}, Account Status: {value}.

  • This looks like a JSON. Know this format?

  • very little, I’m beginner in python.

  • JSON is a structured text format, independent of Python. I suggest you research the basics about it before continuing.

  • I passed that way p/ get that answer.

  • Thanks Anderson, JSON was the answer anyway.. I managed to resolve.

  • By the way, if you are using Requests, Beatifulsoup is unnecessary.

  • Okay, thanks for the tips.

Show 2 more comments

1 answer

1


The URL you are requesting returns a JSON. The Beatifulsoup library serves to parse XML (and, consequently, HTML) documents. That means you don’t have to use it.

The Requests library itself already does everything it needs:

import requests

response = requests.post(url, data)

if response.ok:
    json = response.json()
    world = json['World']
    status = json['Account Status']

Browser other questions tagged

You are not signed in. Login or sign up in order to post.