This file contains hidden or 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_date(soup): | |
| try: | |
| date = " ".join(soup.find("div", class_="title-info-metadata-item-redesign").text.split()[1:]) | |
| if "сегодня" in date: | |
| date = str(datetime.datetime.today()).split()[0] | |
| elif "вчера" in date: | |
| date = str(datetime.datetime.today() - datetime.timedelta(days=1)).split()[0] | |
| else: | |
| date = "too old" | |
| except Exception as e: |
This file contains hidden or 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_total_pages(html): | |
| soup = BeautifulSoup(html, "lxml") | |
| try: | |
| pages = soup.find("div", class_="pagination-pages clearfix") | |
| if pages is not None: | |
| pages.find_all("a", class_="pagination-page")[-1].get("href") | |
| total_pages = int(pages.split("=")[1].split("&")[0]) | |
| else: | |
| catalog = soup.find("div", class_="js-catalog_serp").find_all("div", class_="item_table") | |
| if catalog is not None: |
This file contains hidden or 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
| /* | |
| нужно реализовать паттерн chaining | |
| написать функцию createHash | |
| которая сможет работать вот так: | |
| createHash() | |
| .set('3', 2) | |
| .set('4', 5) |