All pastes #3784890 Raw Edit

Unnamed

public unlisted text v1 · immutable
#3784890 ·published 2017-03-23 13:43 UTC
rendered paste body
import htmlparser
import xmltree  # To use '$' for XmlNode
import strtabs  # To access XmlAttributes
import os       # To use splitFile
import strutils # To use cmpIgnoreCase
import httpclient
import streams



proc getBashQuote(html: string): string =
  let html = parseHtml(newStringStream(html))
  
  for elem in html.findAll("div"):

    if elem.attr("class") == "text":
        echo "test a"
        echo elem
        let text = elem.innerText
        if not text.isNil:
            return text

let client = newHttpClient()
let data = client.get("http://bash.im/quote/444074")
echo getBashQuote(data.body)