⎗ ✓ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49#nim c -d:ssl a13dlme.nim import httpclient,re,strutils,uri,nimquery from xmltree import `$` from htmlparser import parseHtml from streams import newStringStream var ta_url = "https://13dl.me/list/popular/" var counter = 0 proc scrape(url: string,count: int) : (string, int) = var counter = count let data = re"""(?<=title\=\").+?(?=\")""" let pa_tf = re"""^Page""" let p_tf = re"""^Prev""" let ne = re"""(?<=href\=\").+?(?=\")""" let client0 = newHttpClient() let response = client0.get(url) let html = parseHtml(newStringStream(response.body)) client0.close() let a_tag = html.querySelectorAll("a") var next_url = "" for v in a_tag: let vv = findall($v,data) if len(vv) > 0: if (vv[0] == "" or vv[0] == "Home" or vv[0] == "Popular Manga" or vv[0] =="Newest"): discard else: if (match(vv[0],pa_tf)) or (match(vv[0],p_tf)): discard else: if vv[0] == "Next": next_url = findall($v,ne)[0] break else: counter += 1 let num = counter echo num.intToStr & " | " & vv[0] echo "------------------------------------------------------" return (next_url,counter) while( ta_url != ""): (url, counter) = scrape(ta_url,counter)