我编写了两个用于Google搜索结果的爬虫代码。
谷歌网站Chrome搜索(Selenium)/谷歌自定义API搜索(免费,100次查询限制)
当执行这两个代码时,条件相同但结果不同(也许我错了?)
谷歌网站Selenium "url"
GoogleUrl = f'https://www.google.com/search?q={SearchKeyword}+intext:{MUSTKeyword}&hl=en&rlz=&start={pageNum}'
这是我使用的Google API参数。
response = service.cse().list(
q=searchterm_in,
exactTerms=incl_searchterm_in,
siteSearch=sitesearch_in,
cx=my_cse_id,
num=10,
start=index,
).execute()
我认为,“搜索关键字”=“q”,“MUSTKeyword”=“精确条款”。Google API在官方文档中似乎没有“intext:”参数。(https://developers.google.com/custom-search/v1/reference/rest/v1/cse/list)因此,我尝试了“exactTerms”,但是使用Selenium Google搜索结果比API更准确地获取了结果。
问题:如何设置或添加参数到Google API中,以导入与Google Selenium搜索相同的结果?在Google API搜索参数中,什么替代了“intext:”?