Skip to content

support tbs parameter#79

Open
zhuangAnjun wants to merge 5 commits intoNv7-GitHub:masterfrom
zhuangAnjun:master
Open

support tbs parameter#79
zhuangAnjun wants to merge 5 commits intoNv7-GitHub:masterfrom
zhuangAnjun:master

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.

```

### 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.

@pwfreedm
Copy link

@Nv7-GitHub @zhuangAnjun is this going to be merged any time soon? It is a very helpful param to have access to.

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.

4 participants