Created
May 30, 2022 08:50
-
-
Save allatambov/847a73bd0b1f01bdc687b83dd67b06e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_info(my_link): | |
my_page = requests.get(my_link) | |
my_soup = BeautifulSoup(my_page.text) | |
author = my_soup.find("meta", | |
{"name" : "mediator_author"})["content"] | |
date = my_soup.find("meta", | |
{"itemprop" : "datePublished"})["content"] | |
title = my_soup.find("title").text | |
desc = my_soup.find("meta", | |
{"name" : "description"})["content"] | |
div = my_soup.find("div", {"class" : "tables"}) | |
tabs = div.find_all("p") | |
rubs_raw = tabs[0].find_all("a") | |
rubs = [r.text for r in rubs_raw] | |
rubs_str = ", ".join(rubs) | |
time = tabs[1].find("span").text | |
diffc = tabs[2].find("span", {"class" : "difficult-value"}).text | |
pars_raw = my_soup.find_all("p", {"class" : None}) | |
pars_text = [p.text for p in pars_raw] | |
text = " ".join(pars_text) | |
text = text.split("Нашли опечатку?")[0] | |
text = text.replace("\xa0", " ") | |
result = [title, desc, author, date, time, diffc, rubs_str, text] | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment