Add preliminary support for fetching more than 100 articles with dynamic date range adjustments #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For the highly-requested functionality to fetch more than 100 articles, this preliminary implementation uses a sliding time window to bypass Google's RSS feed limit of 100 per query.
If the user requests more than 100 max_results, a new helper function named _get_news_more_than_100() is called. After calling the first 100 results, this function re-queries Google's RSS feed, specifying the 7 days before the earliest published date seen so far as the time window. This allows new articles to be retrieved until max_results articles are fetched, or until the search is exhausted, whichever comes first.
This function currently works by resetting start_date and end_date to their default values. For this reason, fetching more than 100 articles is currently NOT compatible with a user-specified start_date, end_date, or period. If the user specifies any of these parameters, the function will raise a warning and reset start_date and end_date to None before proceeding.
I have added one test case testing this functionality by querying Google News for at most 150 articles, called test_get_news_more_than_100().