Answer the question
In order to leave comments, you need to log in
How to get data from website using BeautifulSoup?
Please tell the 1C programmer how to adapt the script in python? I see python 2 times, just forced)
How to return the number "2390.00" using BeautifulSoup?
Now there is a script for the megaphone website, it works:
browser.get('https://b2blk.megafon.ru/account/accountInfo/1218****')
time.sleep(2)
text = bs4.BeautifulSoup(browser.page_source)
time.sleep(2)
cash = text.select('.money')[0].getText()
time.sleep(2)
browser.close()
return 'MEG_balance: ' + cash + '\n'
Answer the question
In order to leave comments, you need to log in
just forced
This problem is solved quite simply. I think further you will modify the code by analogy with your script for a megaphone.
#!/usr/bin/env python3
import requests
from bs4 import BeautifulSoup
html = '<span class="content"><div class="ng-star-inserted">2 390,00 r</div></span>'
soup = BeautifulSoup(html, 'html.parser')
cash = soup.find('span', attrs = {'class':'content'}).find('div', attrs = {'class':'ng-star-inserted'}).get_text().strip()
print(cash)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question