How to keep only a certain part of a string, and a certain amount of characters after it

I’m trying to make a script that will get the current sell price of an item in a game, and I want it to end up printing something along the lines of:


However, the number (shown as 1451.1 in the example) frequently changes, and I am not able to only get this number alone as an output because there are many other numbers in the string, and they are also frequently changing. I tried to replace everything but the part of the string that I want, but since there are so many numbers that are frequently changing, I was unable to do so. I was thinking it might be possible to find the word "sellPrice" in the string, since it never changes, and then just print a certain amount of characters after it. However, I can’t find out how to do this and was wondering if there are any other solutions.

The website I am getting the data from is this, and the large block of text on the page is the string that I’m trying to use to find the sell price.

My current code (prints entire HTML of the website, with no sorting):

import requests

URL = ""
page = requests.get(URL)


I am pretty new to python / coding in general, so I’m sorry in advance if there is some blatantly obvious solution to this that I just don’t know yet. Thanks!

>Solution :

As per Pranav – use JSON:

import requests

URL = ""
page = requests.get(URL)
data = page.json()
sellPrice = data['sellPrice']

print(f'Sell Price: {sellPrice}')


Sell Price: 1378.5

Leave a Reply