Content parsing (Python, BeautifulSoup, requests)

Here is the code:

from bs4 import BeautifulSoup

html = requests.get('https://kaliningrad.bankiros.ru/currency/').text
soup = BeautifulSoup(html, 'lxml')

div_tags1 = soup.find_all('td', {'class': 'currency-value'})
img_tags1 = [div.find('span') for div in div_tags1]

image_src1 = [img['data-curse-val'] for img in img_tags1]

valist = list(image_src1)

print(valist)

I'm still learning to parse and I don't understand why an empty list is passed at the output, because everything seems to be done as always.

How can I parse the currency from the site https://kaliningrad.bankiros.ru/currency/ ?

enter a description of the image here

Author: Lev145, 2020-03-22

1 answers

Add the HTTP header User-Agent to your query:

HEADERS = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',  # Example
}
html = requests.get('https://kaliningrad.bankiros.ru/currency/', headers=HEADERS).text
 0
Author: nomnoms12, 2020-03-22 07:53:14