Alexa Rank API using Spring Boot and Jsoup HTML Parser

Ooo… It’s been a while since I wrote an article. I was searching for Alexa Rank API for one of my projects unfortunately Alexa Web Information Service offers only 1000 requests per month for free so thought of Scraping the Alexa Page as a fun project.

In case you need a official Paid API – go here

It’s a fairly simple project, feel free to modify to add more functionality.

Requirements:

  • Spring Boot Framework (To create the API and a Standalone Application)
  • Jsoup HTML Parser (To Parse the Alexa Page and get our desired output)
  • Json Library (To create a JSON format output)

Both of them can be added using the maven dependencies as below.

Pom.xml (Maven Configurations)

I’ve created a bunch of classes to make sure the Application works properly. I’ve explained all the classes and its uses below.

Initiate your SpringBootApplication from the Main() class.

Controller.java (Controls the API calls and returns the JSON outputs)

DomainAnalyser.java ( Validates the requesting domain is valid or not)

JsonOutput.java (Creates a Json output)

ProxyManager.java (Incase if your server requires a custom proxy to connect with different hosts, you can configure and initiate in Main Class )

Scrapper.java (Calls the Alexa Page and Extract the rank)

The output will look like this.

Please leave a comment below if you’re facing any issues with the code. Thank you for your time, see you around.