Multiple file types search using Google Custom Search API

安稳与你 提交于 2019-12-08 00:29:36

问题


I need to get Google search results for particular filetypes. For example, in browser I would directly google search for "hyperloop filetype:pdf" and it will list out PDF files for "Hyperloop". For this, my Google Custom Search request URI will be https://www.googleapis.com/customsearch/v1?key=MY_KEY&cx=MY_UNIQUE_ID&q=hyperloop&fileType=pdf

However, currently I would like to get search results for "hyperloop" of filetypes .ppt or .doc. In browser, I would achieve this by googling "hyperloop filetype:ppt OR filetype:doc".

What will be my Search request URI equivalent for this query? I could not find anything related to querying using multiple values for a single parameter in Google Custom Search Documentation.


回答1:


Rather than doing

q=hyerloop&filetype=pdf

you can use

q=hyperloop%20filetype:pdf%20OR%20filetype:doc



回答2:


use this its work

  $url='https://www.googleapis.com/customsearch/v1?key=AIzaSyCJUGIb_tevRKD-Kxxi5f4&cx=010407088:onjj7gscy2g&q='.  urlencode($keywords).'&filetype=doc&filetype=docx';

for me



来源:https://stackoverflow.com/questions/18901738/multiple-file-types-search-using-google-custom-search-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!