我正在通过api google custom search
使用google_api_client python
。我想检索特定查询的pdf文档。下面是执行此功能的函数。
def query_results(service,q=None,startIndex=1,siteSearch=None,fileType=None):
return service.cse().list(
q=q,
cx='000906600611484344115:o9lfdh9y1m5',
start=startIndex,
siteSearch=siteSearch,
fileType=fileType,
safe='off'
).execute()
当我通过q="alienware", filetype="pdf" and siteSearch="google.com"
调用上述方法时,几乎没有得到一个结果。但是,当我通过浏览器在Google搜索中键入相同的查询filetype:pdf alienware
时,I got plenty of results.
我做错了吗?或api本身是否有问题?
[当我说I got plenty of results
时,我的意思是下面的图像
指定siteSearch="google.com"
表示您只会在google.com上搜索页面。等效于在Google上搜索site:google.com
。删除siteSearch,您将获得预期的结果。