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.
Join the DZone community and get the full member experience.
Join For Freein 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:
2. https://soundcloud.com/stream
you can find the complete code here .
the build.sbt file of the project contains all dependencies.
the
urlmetadataactor.scala
file gets the data from the url.
now, let's look at an example of the tool doing its work:
and there you have it! you've pulled metadata from a url with scala, akka-http, and the open graph protocol.
resources
thanks!
Published at DZone with permission of Dhirendra Kumar Kashyap, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments