文件类型是否等于python中的google cse列表中的pdf文件

问题描述 投票:0回答:1

我正在通过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时,我的意思是下面的图像

enter image description here

下面是自定义搜索的配置enter image description here

python-3.x google-api-client google-search-api
1个回答
0
投票

指定siteSearch="google.com"表示您只会在google.com上搜索页面。等效于在Google上搜索site:google.com。删除siteSearch,您将获得预期的结果。

© www.soinside.com 2019 - 2024. All rights reserved.