S
S
s75002021-03-24 15:43:09
Python
s7500, 2021-03-24 15:43:09

How to extract numbers from a tag?

I want to get the central bank rate without using beautiful soup.
I parsed the page and using regular expressions I try to pull out the dollar rate, but it only comes out with tags for me

import requests
import re

import pprint


url = 'https://www.cbr.ru/currency_base/daily/'

request = requests.get(url)
data = request._content.decode('utf-8')
match = re.search(r'Доллар США.*?(\d+,\d+)', data, re.IGNORECASE | re.DOTALL)
pprint.pprint(match)

the output is the following:
<re.Match object; span=(19252, 19290), match='Доллар США</td>\r\n          <td>76,1535'>

I messed up something with the regular expressions, but I can not understand what exactly

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2021-03-24
@s7500

match.group(1)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question