replace-bot/parser/utils.py
2022-10-28 13:57:30 +03:00

32 lines
817 B
Python

from bs4 import BeautifulSoup
def table_parser(soup: BeautifulSoup, output):
#Date parser
date = (soup.find("main").findAll('span', style="color:black"))[1]
output["date"] = date.text.replace(u'\xa0', u'')
#Replaces parser
replaces = soup.findAll('tr')
for data in replaces:
text = (
data.find("td", valign="top")
.find("span", style="color:black")
.text.replace(u'\xa0', u'')
)
group = (
data.find("span", style="color:black")
.text.replace(" ", "").replace(u'\xa0', u''))
output["data"][group] = text
return output
def image_parser(soup: BeautifulSoup):
main = soup.find("main")
image = main.select_one('img[src$=".jpg"]')
output = image['src']
return output