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

support tbs parameter #79

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

zhuangAnjun
Copy link

Time-Based Search (tbs) Parameter

You can also refine search results based on time. The tbs parameter allows you to filter results by various time ranges. For instance, to get results from the past hour, use qdr:h, or for results from the past year, use qdr:y. Here's how you can use the tbs parameter:

from googlesearch import search
search("Google", tbs="qdr:h")  # Results from the past hour
search("Google", tbs="qdr:m")  # Results from the past month
search("Google", tbs="qdr:y")  # Results from the past year

@Nv7-GitHub
Copy link
Owner

Are there any parameters to tbs that don't start with qdr:?

@zhuangAnjun
Copy link
Author

Are there any parameters to tbs that don't start with qdr:?

Here are some common tbs filter options:

qdr: Time filter (e.g., h for hour, d for day, w for week, m for month, y for year)
sbd: Search by domain (e.g., 1 for Google-approved sites only)
li: Include images (e.g., 1 to include image results)
vid: Include videos (e.g., 1 to include video results)
nws: Include news (e.g., 1 to include news results)
bks: Include books (e.g., 1 to include book results)
stn: Include visited sites (e.g., 1 to include sites you've visited)
sur: Search language (e.g., fxc for English, zh-CN for Chinese)
ctr: Country (e.g., US for United States, CN for China)
rfsn: Site ID (e.g., 474624 for a specific site ID)

@Nv7-GitHub
Copy link
Owner

Interesting! Can you add these to the README?

Copy link
Owner

@Nv7-GitHub Nv7-GitHub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! I've added this review so that I can keep track of pull requests that are ready to be merged.

@@ -25,6 +25,16 @@ In addition, you can change the language google searches in. For example, to get
from googlesearch import search
search("Google", lang="fr")
```

### Time-Based Search (tbs) Parameter
You can also refine search results based on time. The tbs parameter allows you to filter results by various time ranges. For instance, to get results from the past hour, use `qdr:h`, or for results from the past year, use `qdr:y`. Here's how you can use the tbs parameter:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add information about non-qdr options?

@fernandobnog
Copy link

Hi everyone,

I've noticed that some filters modify the HTML structure in ways that might break the scraping process. From what I understand (though I might be mistaken), it seems that only the time filter (qdr) and the language filter (sur) keep the search functionality working as expected.

Thanks a lot.

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

Successfully merging this pull request may close these issues.

3 participants