Nv7-GitHub / googlesearch

A Python library for scraping the Google search engine.
https://pypi.org/project/googlesearch-python/
MIT License
430 stars 110 forks source link

support tbs parameter #79

Open zhuangAnjun opened 3 months ago

zhuangAnjun commented 3 months ago

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 commented 3 months ago

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

zhuangAnjun commented 3 months ago

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 commented 2 months ago

Interesting! Can you add these to the README?