GithubHelp home page GithubHelp logo

trestianp / aws-java-sdk-awis Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tahseen/aws-java-sdk-awis

0.0 2.0 0.0 173 KB

Amazon Alexa Web Information Service Client written in Java

Java 100.00%

aws-java-sdk-awis's Introduction

Alexa Web Information Service is a bit of a mess. This is an attempt to provide a client that works.

The response classes return by the client are generated by JAXB. They will work but it feel like Amazon did a patch on some old legacy system to get this service to work. So you end up with typical over engineered Java class structure. This is something I plan to improve by replacing JAXB with simple response classes.

This client simplify requesting these services. Below is the example of calls to AWIS.

Credentials

The client accept Amazon AWS SDk credientials. Remember AWIS service only work with ROOT access key and secret. You can't use Amazon AWS AMI credentials.

DefaultAWSCredentialsProviderChain defaultAWSCredentialsProviderChain = new DefaultAWSCredentialsProviderChain();
credentials = defaultAWSCredentialsProviderChain.getCredentials();

UrlInfo

The UrlInfo action provides information about a website, such as:

  • how popular the site is
  • what sites are related
  • contact information for the owner of the site
AlexaWebInformationServiceClient client = new AlexaWebInformationServiceClient(credentials);

UrlInfoRequest request = new UrlInfoRequest();
request.setResponseGroups(Arrays.asList(GetUrlInfoResponseGroup.values()));
request.setUrl("www.bryght.com");

UrlInfoResponse response = client.getUrlInfo(request);

Assert.assertNotNull(response);
Assert.assertNotNull(response.getResponse());
Assert.assertNotNull(response.getResponse().getUrlInfoResult().get(0));
Assert.assertNotNull(response.getResponse().getUrlInfoResult().get(0).getAlexa().getContactInfo());
Assert.assertNotNull(response.getResponse().getUrlInfoResult().get(0).getAlexa().getContentData());
Assert.assertNotNull(response.getResponse().getUrlInfoResult().get(0).getAlexa().getRelated());
Assert.assertNotNull(response.getResponse().getUrlInfoResult().get(0).getAlexa().getTrafficData());

TrafficHistory

The TrafficHistory action returns the daily Alexa Traffic Rank, Reach per Million Users, and Unique Page Views per Million Users for each day since August 2007. This same data is used to produce the traffic graphs found on alexa.com.

AlexaWebInformationServiceClient client = new AlexaWebInformationServiceClient(credentials);

TrafficHistoryRequest request = new TrafficHistoryRequest();
request.setUrl("www.bryght.com");
request.setRange(20);

Calendar start = GregorianCalendar.getInstance();
start.set(Calendar.YEAR, 2015);
start.set(Calendar.MONTH, 1);
start.set(Calendar.DAY_OF_MONTH, 1);

request.setStart(start.getTime());

TrafficHistoryResponse response = client.getTrafficHistory(request);
       
Assert.assertNotNull(response);
Assert.assertNotNull(response.getResponse());
Assert.assertNotNull(response.getResponse().getTrafficHistoryResult().get(0));
Assert.assertNotNull(response.getResponse().getTrafficHistoryResult().get(0).getAlexa().getTrafficHistory());

CategoryBrowse

The CategoryBrowse action and CategoryListings actions together provide a directory service based on the Open Directory, www.dmoz.org, and enhanced with Alexa traffic data.

For any given category, the CategoryBrowse action returns a list of sub-categories. Within a particular category you can use the CategoryListings action to get the documents within that category ordered by traffic.

AlexaWebInformationServiceClient client = new AlexaWebInformationServiceClient(credentials);

CategoryBrowseRequest request = new CategoryBrowseRequest();
request.setResponseGroups(Arrays.asList(CategoryBrowseResponseGroup.values()));
request.setPath("Top/Shopping");
request.setDescriptions(Boolean.TRUE);

CategoryBrowseResponse response = client.getCategoryBrowse(request);

Assert.assertNotNull(response);
Assert.assertNotNull(response.getResponse());
Assert.assertNotNull(response.getResponse().getCategoryBrowseResult().get(0));
Assert.assertNotNull(response.getResponse().getCategoryBrowseResult().get(0).getAlexa().getCategoryBrowse());

CategoryListings

The CategoryListings action is a directory service based on the Open Directory, www.dmoz.org. For any given category, it returns a list of site listings contained within that category.

AlexaWebInformationServiceClient client = new AlexaWebInformationServiceClient(credentials);
 
CategoryListingsRequest request = new CategoryListingsRequest();
request.setPath("Top/Business/Automotive");
request.setRecursive(Boolean.TRUE);
request.setStart(1);;
request.setCount(15);
request.setSortBy(SortBy.Popularity);
request.setDescriptions(Boolean.TRUE);

CategoryListingsResponse response = client.getCategoryListings(request);

Assert.assertNotNull(response);
Assert.assertNotNull(response.getResponse());
Assert.assertNotNull(response.getResponse().getCategoryListingsResult().get(0));
Assert.assertNotNull(response.getResponse().getCategoryListingsResult().get(0).getAlexa().getCategoryListings());

SitesLinkingIn

The SitesLinkingIn action returns a list of web sites linking to a given web site. Within each domain linking into the web site, only a single link - the one with the highest page-level traffic - is returned.

WARNING: Last time i check Amazon was not returning any results for this service.

AlexaWebInformationServiceClient client = new AlexaWebInformationServiceClient(credentials);

SitesLinkingInRequest request = new SitesLinkingInRequest();
request.setUrl("www.bryght.com");
request.setStart(0);
request.setCount(15);

SitesLinkingInResponse response = client.getSitesLinkingIn(request);

Assert.assertNotNull(response);
Assert.assertNotNull(response.getResponse());
Assert.assertNotNull(response.getResponse().getSitesLinkingInResult().get(0));
Assert.assertNotNull(response.getResponse().getSitesLinkingInResult().get(0).getAlexa().getSitesLinkingIn()); 

Maven Dependencies

You can use the the library my adding following dependencies in your maven project.

<repositories>
	<repository>
		<id>tahseen.distributary.net</id>
		<name>tahseen.distributary.net</name>
		<url>http://tahseen.distributary.net/release/</url>
		<snapshots>
			<enabled>false</enabled>
		</snapshots>
	</repository>
</repositories>

<dependencies>
	<dependency>
		<groupId>net.distributary.tahseen</groupId>
		<artifactId>aws-java-sdk-awis</artifactId>
		<version>0.1</version>
	</dependency>
</dependencies>

aws-java-sdk-awis's People

Contributors

tahseen avatar

Watchers

James Cloos avatar Paul Trestian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.