Advertisement
Tiberium

Untitled

Mar 23rd, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nim 0.47 KB | None | 0 0
  1. import htmlparser
  2. import xmltree  # To use '$' for XmlNode
  3. import httpclient
  4. import streams
  5. import encodings
  6.  
  7.  
  8. proc getBashQuote(html: string): string =
  9.   let html = parseHtml(newStringStream(html))
  10.  
  11.   for elem in html.findAll("div"):
  12.  
  13.     if elem.attr("class") == "text":
  14.         let text = elem.innerText
  15.         return text
  16.  
  17. let client = newHttpClient()
  18. let data = client.get("http://bash.im/quote/444074")
  19. echo getBashQuote(data.body).convert("UTF-8", "CP1251")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement