28 lines
699 B
Nim
28 lines
699 B
Nim
import db_sqlite, future, htmlparser, httpclient, q, strtabs, xmltree, ../twtxt
|
|
|
|
let
|
|
reshtml = "http://twtxt.reednj.com/".getContent
|
|
doc = reshtml.q
|
|
users = doc.select "table tbody tr a.user-link"
|
|
feedurls = doc.select "table tbody tr td a.wide-only"
|
|
|
|
var
|
|
usernames = newSeq[string]()
|
|
feeds = newSeq[string]()
|
|
|
|
for user in users.items:
|
|
usernames.add user.innerText[1..^1]
|
|
|
|
for feed in feedurls.items:
|
|
feeds.add feed.attrs["href"]
|
|
|
|
let db = open("../../data/twtxt.db", nil, nil, nil)
|
|
|
|
for i, user in usernames.pairs:
|
|
let url = feeds[i]
|
|
echo i, " ", user, " ", url
|
|
|
|
try:
|
|
db.exec(sql"insert into users values(null, ?, ?)", user, url)
|
|
except: echo getCurrentExceptionMsg()
|