T
T
texnik22052020-08-03 17:13:12
Python
texnik2205, 2020-08-03 17:13:12

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)
5f281a04eb47b816976842.jpeg
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'

Needs to be adapted for MTS

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2020-08-03
@dimonchik2013

just forced

easy to throw off the burden for hard cash to good freelancers

K
Konstantin ™, 2020-08-03
@Energoblock

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 question

Ask a Question

731 491 924 answers to any question