Answer the question
In order to leave comments, you need to log in
How to remove spaces from price value after receiving data from Python 3.8 parser?
Hey! Who can help with the solution to the problem of removing gaps in the price (2,500). The bottom line is that you want to know the price of a share, but a gap interferes with further work with the data. Tried replace(" ", "") but that doesn't help. I also checked the output data type = "class.str", in theory a string, so everything should work or is this separator not a space, as such? To better understand the question, here is the parser code:
import requests
from bs4 import BeautifulSoup
url = "https://www.finam.ru/profile/moex-akcii/qiwi-plc/?market=1"
HEADERS = {"Accept": "*/*", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36"}
def parse():
html = requests.get(url, headers=HEADERS)
if html.status_code == 200:
soup = BeautifulSoup(html.content, "html.parser")
text = soup.find("span", id="issuer-profile-informer-last")
price = text.get_text()
p = price.replace(" ", "")
print(p)
else:
print("Error")
parse()
Answer the question
In order to leave comments, you need to log in
You're not filling that gap. Copy the space from the console when you have the price displayed in the Python console. And substitute it in replace. The gaps are different.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question