Custom user agent

Ref https://github.com/buckket/twtxt/issues/3#issuecomment-182738604
This commit is contained in:
Christine Dodrill 2016-02-11 03:00:58 -08:00
parent b9d2c0fea3
commit 69b3680361
1 changed files with 2 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import db_sqlite, json, httpclient, os, strutils, times, time/gotime
const const
ISOTime*: string = "yyyy-MM-dd'T'HH:mm:ss'.000000+'zzz" ISOTime*: string = "yyyy-MM-dd'T'HH:mm:ss'.000000+'zzz"
version: string = staticExec "git describe --tags --long"
type type
Tweet* = object of RootObj Tweet* = object of RootObj
@ -49,7 +50,7 @@ proc fromDBRow*(r: Row): Tweet =
proc getTweetsFrom*(url: string, username: string): seq[Tweet] = proc getTweetsFrom*(url: string, username: string): seq[Tweet] =
var res = newSeq[Tweet]() var res = newSeq[Tweet]()
let body = url.getContent(timeout=20_000) let body = url.getContent(timeout=20_000, userAgent = "https://twtxtlist.cf " & version & " (+https://xena.greedo.xeserv.us/files/xena.txt; @xena)")
for line in body.splitLines().items(): for line in body.splitLines().items():
if line.len > 0 and line[0] != '#': if line.len > 0 and line[0] != '#':