Google Custom Search - Using REST to Invoke the API

개발공부 2017. 3. 7. 10:25
반응형

Google Custom Search - Using REST to Invoke the API


Google Custom Search - Using REST to Invoke the API

간단히 쿼리를 날려서 결과값 가져오는걸 해보고싶었다..


https://developers.google.com/custom-search/docs/tutorial/introduction



https://developers.google.com/custom-search/json-api/v1/using_rest


Rest API를 사용하려면 아래 3개 파라미터가 필수다.


API key - Use the key query parameter to identify your application.

Custom search engine ID - Use either cx or cref to specify the custom search engine you want to use to perform this search.

Use cx for a search engine created with the Control Panel

Use cref for a linked custom search engine (does not apply for Google Site Search).

If both are specified, cx is used.

Search query - Use the q query parameter to specify your search expression.


API키는 예전에 발급받아놓은게 있어서 패스했다.


커스텀 검색 엔진을 만들어야 한다.

https://developers.google.com/custom-search/docs/tutorial/creatingcse



컨트롤 패널에 들어가서 Add 로 신규 검색엔진을 만드었다.


나는 구글 검색만 활용해볼 생각으로


검색할 사이트는 www.google.com 만 넣었다. 다른 요긴한 사이트가 있으면 추가 예정이다.


언어는 전체로 설정한다.


엔진 이름은 아무거나~


004203102309972051253:prwksdjhwiva 이런 문자열이 생성되는데 이게 바로 cx 라는 값이다.


 쉘에서 INSERT_YOUR_API_KEY를 api로 넣고 돌려보면 잘 돌아간다.!!

GET https://www.googleapis.com/customsearch/v1?key=INSERT_YOUR_API_KEY&cx=017576662512468239146:omuauf_lfve&q=lectures

반응형

'개발공부' 카테고리의 다른 글

svn branch 리스트 확인  (0) 2017.03.23
인코딩 소스 교체 관련  (0) 2017.03.07
[javascript] href hashtag  (0) 2017.03.07
PHP 이모티콘 제거  (0) 2017.03.07
[linux] 우분투 자바 설치  (0) 2017.03.07
posted by 알릿수