Created
June 30, 2019 12:34
-
-
Save let-robots-reign/3f10b5e72f9c6151bf08ba7631561969 to your computer and use it in GitHub Desktop.
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: | |
| with open("logs.txt", "a", encoding="utf8") as file: | |
| file.write(str(e) + " avito get_date\n") | |
| date = "Не указано" | |
| return date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment