文件类型是否等于google cse list中的pdf在python中工作

我正在通过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时,是指下图

文件类型是否等于google cse list中的pdf在python中工作

以下是自定义搜索的配置

文件类型是否等于google cse list中的pdf在python中工作

wyq8965 回答:文件类型是否等于google cse list中的pdf在python中工作

指定siteSearch="google.com"意味着您将仅在google.com上搜索页面。这等效于在Google上搜索site:google.com。删除siteSearch,您应该会得到预期的结果。

本文链接:https://www.f2er.com/2869452.html

大家都在问