Bing Search and Google CSE interface

Interface towards the Bing API and the Google CSE API.

License

License

Categories

Categories

Java Languages
GroupId

GroupId

it.unipi.di.acube
ArtifactId

ArtifactId

bing-api-java
Last Version

Last Version

0.5
Release Date

Release Date

Type

Type

jar
Description

Description

Bing Search and Google CSE interface
Interface towards the Bing API and the Google CSE API.
Project URL

Project URL

http://github.com/marcocor/bing-api-java
Source Code Management

Source Code Management

https://github.com/marcocor/bing-api-java

Download bing-api-java

How to add to project

<!-- https://jarcasting.com/artifacts/it.unipi.di.acube/bing-api-java/ -->
<dependency>
    <groupId>it.unipi.di.acube</groupId>
    <artifactId>bing-api-java</artifactId>
    <version>0.5</version>
</dependency>
// https://jarcasting.com/artifacts/it.unipi.di.acube/bing-api-java/
implementation 'it.unipi.di.acube:bing-api-java:0.5'
// https://jarcasting.com/artifacts/it.unipi.di.acube/bing-api-java/
implementation ("it.unipi.di.acube:bing-api-java:0.5")
'it.unipi.di.acube:bing-api-java:jar:0.5'
<dependency org="it.unipi.di.acube" name="bing-api-java" rev="0.5">
  <artifact name="bing-api-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='it.unipi.di.acube', module='bing-api-java', version='0.5')
)
libraryDependencies += "it.unipi.di.acube" % "bing-api-java" % "0.5"
[it.unipi.di.acube/bing-api-java "0.5"]

Dependencies

compile (7)

Group / Artifact Type Version
org.codehaus.jettison : jettison jar 1.3.6
commons-io : commons-io jar 1.3.2
org.apache.httpcomponents : httpclient jar 4.5.2
org.apache.httpcomponents : httpcore jar 4.4.4
org.jsoup : jsoup jar 1.10.1
org.mapdb : mapdb jar 3.0.2
org.slf4j : slf4j-simple jar 1.7.21

Project Modules

There are no modules declared in this project.

Bing and Google CSE API library for Java

A small set of Java classes to query the Bing Search and the Google CSE (Custom Search Engine) APIs.

The library is published on Maven Central, you can include it as a dependency in your pom.xml file as:

<dependency>
	<groupId>it.unipi.di.acube</groupId>
	<artifactId>bing-api-java</artifactId>
</dependency>

Registration to the APIs

By using this library you accept that it may issue any number of calls to the search engines API on your account, which may results in spending your credit or money.

  • To use the Google CSE API, you need to setup a Google Custom Search Engine and create an API key from the Google Developers Console. For an example of building a generic CSE for the whole web, see here (Sections "Setting up Google CSE" and "Enabling the Google API").
  • To use the Bing API, register to the Bing Web Search API.

Usage

1- Create a SearchApiCaller for either Bing:

BingSearchApiCaller caller = new BingSearchApiCaller("<MY_BING_KEY>");

or Google CSE:

GoogleSearchApiCaller caller = new GoogleSearchApiCaller("<MY_CSE_ID>", "<MY_GOOGLE_API_KEY>");

2- Create a wrapper for the caller that will take care of performing multiple-calls queries:

WebsearchApi api = new WebsearchApi(caller);

Alternatively, if you need result caching, you may create a cached wrapper:

CachedWebsearchApi api = CachedWebsearchApi.builder().api(caller).path("<CACHE_FILE_NAME>").create();

Cached wrappers will store query responses in a file and will not re-issue the same query twice.

3- Now you can issue calls with:

WebsearchResponse response = api.query("QUERY_TEXT", NUMBER_OF_RESULTS_NEEDED);

response will contain all information returned by the search engine's API.

You can see a full example of a command-line script for Bing or Google.

Contacts

For any bug you encounter, you can open a bug report on github.

For any enquiry, send an email at x at di.unipi.it (replace x with 'cornolti')

Enjoy, Marco

Versions

Version
0.5
0.4
0.3