Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter by date #56

Closed
anath2 opened this issue Jun 12, 2018 · 3 comments
Closed

Filter by date #56

anath2 opened this issue Jun 12, 2018 · 3 comments

Comments

@anath2
Copy link

anath2 commented Jun 12, 2018

Hi, is there a way to filter results by date in the search output?

@JuaniFilardo
Copy link
Collaborator

Hi, afaic there are not many google results that include the date of the page/article; could you send an example? As it's not so common, the date isn't included in the attributes of the GoogleResult object.
I guess you could add this attribute (as a datetime object, not the string) and then check if there's a date in the result, otherwise set it to None. Then filtering should be applied in your code.

PS: I just checked and when you manually search in Google you can go to Tools and change the parameter "Any time" to any of the other options (past year, past day, etc). I thought that was most likely to be set in the GET parameters, and so it is:

q=kurt+vonnegut&safe=off&client=psy-ab&hl=en-AR&source=lnt&tbs=qdr:w&sa=X&sqi=2&ved=0ahUKEwje5J_7lc7bAhWprVQKHblUDa8QpwUIIA&biw=959&bih=885

q=kurt+vonnegut&safe=off&client=psy-ab&hl=en-AR&source=lnt&tbs=qdr:y&sa=X&ved=0ahUKEwjRyc2cls7bAhWHn4MKHeWjBtIQpwUIHw&biw=959&bih=885

Pay attention to the bold part. The first one searches for results of the past week, while the second one searches the last year.
I'm pretty busy at the moment but if someone wants to, they can record every one of these options and then set a parameter in the code that passes the correct GET parameter in order to filter by date (users should also be able to select by which parameter they want to search, in the search() method). If I remember correctly, the feature of 'tuning' the URL belongs to utils.py.

@anath2
Copy link
Author

anath2 commented Jun 13, 2018

I submitted a pull request for this :
ajcasagrande#2

@JuaniFilardo
Copy link
Collaborator

That's great. I quickly looked at your code and it seems alrigth, could you please also submit that pull request to this repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants