项目作者: esafirm

项目描述 :
Kotlin DSL to scrape HTML and convert it to JSON
高级语言: Kotlin
项目地址: git://github.com/esafirm/skrape.git
创建时间: 2017-07-10T10:59:03Z
项目社区:https://github.com/esafirm/skrape

开源协议:MIT License

下载


OSS Skrape Banner

Skrape

Turn your HTML to JSON with graph based Kotlin DSL 💪

Support Me!

I would make myself more commited to this repo and OSS works in general.

Would you help me achieving this goals?

Buy Me a Coffee at ko-fi.com

Getting Started

Define your query in type-safe Kotlin DSL

  1. Page("https://news.ycombinator.com/") {
  2. "items" to query("td a.storylink") {
  3. "text" to text()
  4. "info" to container {
  5. "link" to attr("href")
  6. }
  7. }
  8. }.run {
  9. Skrape(JsoupDocumentParser()).request(this)
  10. }

To predictable JSON result

  1. {
  2. "items": [
  3. {
  4. "text": "SFO near miss could have triggered \u2018greatest aviation disaster in history'",
  5. "detail": {
  6. "link": "http://www.mercurynews.com/2017/07/10/exclusive-sfo-near-miss-might-have-triggered-greatest-aviation-disaster-in-history/"
  7. }
  8. },
  9. {
  10. "text": "Taking control of all .io domains with a targeted registration",
  11. "detail": {
  12. "link": "https://thehackerblog.com/the-io-error-taking-control-of-all-io-domains-with-a-targeted-registration/"
  13. }
  14. }
  15. ]
  16. ...
  17. }

Binaries

Add to your root build.gradle

  1. allprojects {
  2. repositories {
  3. ...
  4. maven { url 'https://jitpack.io' }
  5. }
  6. }

Then add the dependency

  1. dependencies {
  2. compile 'com.github.esafirm:skrape:x.y.z'
  3. }

Where x.y.z is the latest release (can be viewed from Github release page or Badge.

License

MIT