W
W
why22021-03-31 18:24:24
Python
why2, 2021-03-31 18:24:24

beautifulsoup. How to parse a page?

I don't understand how to parse a page using BeautifulSoup. url: https://www.banki.ru/products/currency/usd/
You need to pull out the course for the past day.
30.03 75.8287 +0.0711
Tried like this:

full_page = requests.get(url, headers = headers)
soup = BeautifulSoup(full_page.content, 'html.parser')
conver = soup.findAll('tr', {'class': "cb-current-rates__list__item"})
cuu = conver[0].text
print(str(cuu))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
galaxy, 2021-03-31
@galaxy

Through JS they are reloaded there.

curl 'https://www.banki.ru/products/currency/ajax/quotations/history/cbr/' -H 'Content-Type: application/json' -H 'X-Requested-With: XMLHttpRequest' -H 'Origin: https://www.banki.ru' --data-raw '{"currency_id":840,"from":1609362000}'

{
  "currency_id": 840,
  "history": {
    "1609362000": 73.8757,
    "1609448400": 73.8757,
    "1610398800": 74.5157,
    "1610485200": 74.2663,
    "1610571600": 73.5264,
    "1610658000": 73.7961,
    "1610744400": 73.5453,
    "1611003600": 73.9735,
    "1611090000": 73.7243,
    "1611176400": 73.355,
    "1611262800": 73.3694,
    "1611349200": 74.3615,
    "1611608400": 74.8569,
    "1611694800": 75.6354,
    "1611781200": 75.04,
    "1611867600": 76.1854,
    "1611954000": 76.2527,
    "1612213200": 75.5053,
    "1612299600": 75.9051,
    "1612386000": 76.0801,
    "1612472400": 75.7293,
    "1612558800": 75.1107,
    "1612818000": 74.2602,
    "1612904400": 74.1192,
    "1612990800": 73.8526,
    "1613077200": 73.7579,
    "1613163600": 73.9378,
    "1613422800": 73.3092,
    "1613509200": 73.2895,
    "1613595600": 73.7669,
    "1613682000": 73.7755,
    "1613768400": 73.9717,
    "1613854800": 73.9833,
    "1614200400": 73.7532,
    "1614286800": 73.4747,
    "1614373200": 74.4373,
    "1614632400": 74.0448,
    "1614718800": 74.5755,
    "1614805200": 73.5187,
    "1614891600": 73.7864,
    "1614978000": 74.4275,
    "1615323600": 74.264,
    "1615410000": 74.0393,
    "1615496400": 73.4996,
    "1615582800": 73.5081,
    "1615842000": 73.2317,
    "1615928400": 72.9619,
    "1616014800": 73.1019,
    "1616101200": 73.6582,
    "1616187600": 74.139,
    "1616446800": 74.6085,
    "1616533200": 75.3585,
    "1616619600": 76.1535,
    "1616706000": 76.1741,
    "1616792400": 75.7576,
    "1617051600": 75.8287,
    "1617138000": 75.7023,
    "1617224400": 75.6373
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question