Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AlgorithmAlchemy/4a4f377758674f27a9e85007dfe0c429 to your computer and use it in GitHub Desktop.
Save AlgorithmAlchemy/4a4f377758674f27a9e85007dfe0c429 to your computer and use it in GitHub Desktop.
parser?
from bs4 import BeautifulSoup
import requests
import sqlite3
import matplotlib
db = sqlite3.connect('posts.sqlite', check_same_thread=False)
connect = db.cursor()
connect.execute('''CREATE TABLE IF NOT EXISTS price (
id INTEGER PRIMARY KEY AUTOINCREMENT,
full_name TEXT,
short_name TEXT,
procent TEXT,
data TEXT,
price TEXT
)''')
r = requests.get("https://open-broker.ru/analytics/dividend-calendar/")
soup = BeautifulSoup(r.text, 'html.parser')
table = soup.find('tbody').find_all('tr')
# Тут я нашел таблицу, добрался до нее и записал в переменную table, теперь я могу спокойно к ней обращаться, так как это объект soup
for data in table:
full_name = (data.find(class_="PaymentsCalendar_cellContentChildren__D6vmx").text)
short_name = (data.find(class_="Text_p5__G_U7N Text_p--color-gray__ld8xq Text_p--font-variant-inter-medium___QFLc Text_uppercase__m1mox").text)
procent = (data.find(class_="Text_p3__gPt1d Text_p--mode-relative__p_124 Text_p--color-black__yElui Text_p--font-variant-inter-medium___QFLc PaymentsCalendar_cellContent__yJBex").text)
data = (data.find(class_="Text_p3__gPt1d Text_p--mode-relative__p_124 Text_p--color-black__yElui Text_p--font-variant-inter-medium___QFLc PaymentsCalendar_cellContent__yJBex PaymentsCalendar_buyDate__eblem").text)
price = (data.find(class_="Text_p3__gPt1d Text_p--color-black__yElui Text_p--font-variant-inter-medium___QFLc PaymentsCalendar_cellContent__yJBex DividendCalendarTable_priceCellTextWrapper__6vpW1").text)
inf_list = (full_name, short_name, procent, data, price)
print(inf_list)
db.execute('''INSERT INTO price(full_name, short_name, procent, data, price) VALUES(?, ?, ?, ?, ?)''', inf_list)
db.commit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment