Created
May 26, 2018 15:57
-
-
Save ihfazhillah/b680f63c7f8558f51204263a237a1465 to your computer and use it in GitHub Desktop.
iterating over all urls from Url objects.
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
| """ | |
| 1. iterate over all urls | |
| 2. parse | |
| 3. if item not in database: create notification and save | |
| 4. else: pass | |
| """ | |
| for url in Url.objects: | |
| parsed = feedparser.parse(url.url) # note that we need the url attribute not Url object in order to parsing rss | |
| # iterate over all entries | |
| for item in parsed.entries: | |
| found = Item.objects(guid=item.guid) | |
| # if not in database | |
| if found.count() == 0: | |
| # create dummy notification | |
| print("notify") | |
| # save in database | |
| to_save = Item(title=item.title, description=item.description, guid=item.guid) | |
| to_save.save() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment