Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Anyone know if there is a way to enable a user to specify/filter a date to only search for posts which are posted on a particular date when using googleapiclient?

I am thinking this may be possible because when we go onto Google's page and search for something, on the next page where it's displaying all the searched links, on the top right there is a "Tools" button that you can click on -> click "Any Time" -> click "Custom range" and this will let you specify the date of all the links that was posted on a particular date.

I was hoping that there would be a date parameter in googleapiclient but when I ran my code below which has the date parameter, it comes up with an error TypeError: Got an unexpected keyword argument date. The code works when I remove the date parameter.

from googleapiclient.discovery import build

class GoogleChat():
    def __init__(self):
        # init google search engine
        self.service = build(
            # https://developers.google.com/custom-search/v1/introduction
            "customsearch", "v1", developerKey="MY-DEVELOPER-KEY"
        )

    def _search(self, query, date):
        # call google search api
        response = (
            self.service.cse()
            .list(
                q=query,
                cx="MY-SEARCH-ENGINE-ID", # https://programmablesearchengine.google.com/controlpanel/all
                date=date
            )
            .execute()
        )
        return response['items']

Would greatly appreciate it if anyone could help.

You must be logged in to vote

Replies: 1 comment

Comment options

Did you get any solution?

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.