-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.2.py
More file actions
33 lines (25 loc) · 1.58 KB
/
Copy path2.2.py
File metadata and controls
33 lines (25 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import requests
from bs4 import BeautifulSoup
# URL-адрес для получения данных по котировкам акций
url = 'https://mfd.ru/marketdata/?id=5&group=16&mode=3&sortHeader=name&sortOrder=1&selectedDate=01.11.2019'
# Выполнение GET-запроса к указанному URL-адресу
response = requests.get(url)
# Создание объекта BeautifulSoup для парсинга HTML-страницы
soup = BeautifulSoup(response.content, 'html.parser')
# Поиск таблицы с данными по котировкам акций
table = soup.find('table', class_='js-table-sorter mfd-table')
# Инициализация переменных для хранения информации о максимальном росте числа сделок
max_growth = 0
max_growth_ticker = ''
# Перебор строк таблицы с данными по котировкам акций
for row in table.find_all('tr'):
# Проверка наличия данных в строке
if len(row.find_all('td')) > 1:
# Извлечение тикера и процентного изменения числа сделок
ticker = row.find_all('td')[0].text.strip()
growth = row.find_all('td')[10].text.strip()
# Проверка, является ли текущий рост числа сделок максимальным
if growth and float(growth) > max_growth:
max_growth = float(growth)
max_growth_ticker = ticker
print(max_growth_ticker)