Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Retrieving Data Using Akka-HTTP, Open Graph, and Scala

DZone's Guide to

Retrieving Data Using Akka-HTTP, Open Graph, and Scala

Using standard Scala with the AKKA-HTTP library you can retrieve any metadata and open graph data — useful for cleanly parsing web pages and getting content provider annotated data.

Free Resource

Are you joining the containers revolution? Start leveraging container management using Platform9's ultimate guide to Kubernetes deployment.

In this blog, we are using Akka-HTTP and the Open Graph protocol to retrieve data from a URL.

Open Graph Protocol

The Open Graph protocol enables any web page to become a rich object in a social graph. For instance, this is used on Facebook to allow any web page to have the same functionality as any other object on Facebook.

While many different technologies and schemas exist and could be combined together, there isn’t a single technology that provides enough information to richly represent any web page within the social graph.

With the help of the Open Graph protocol and Akka-HTTP, I developed a mini project that can retrieve data from a URL, like:

1. https://www.youtube.com/

2. https://soundcloud.com/stream

You can find the complete code here.

The build.sbt file of the project contains all dependencies.

Image title

The UrlMetaDataActor.scala file gets the data from the URL.

Image title

Now, let's look at an example of the tool doing its work:

Image title

And there you have it! You've pulled metadata from a URL with Scala, Akka-HTTP, and the Open Graph protocol.

Resources

Thanks!

Using Containers? Read our Kubernetes Comparison eBook to learn the positives and negatives of Kubernetes, Mesos, Docker Swarm and EC2 Container Services.

Topics:
scala ,akka ,open graph ,java

Published at DZone with permission of Dhirendra Kumar Kashyap, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}