Add workaround for Twitter's layout A/B testing

Fixes #110
This commit is contained in:
Zed
2020-01-19 08:34:32 +01:00
parent 6b16ad2ce0
commit ba57511a01
10 changed files with 43 additions and 21 deletions

16
src/api/cookie.nim Normal file
View File

@@ -0,0 +1,16 @@
import httpclient, strutils
proc getGuestId*(): string =
let client = newHttpClient()
for i in 0 .. 10:
try:
let req = client.get("https://twitter.com")
if "react-root" in req.body: continue
for k, v in req.headers:
if "guest_id" in v:
return v[v.find("=") + 1 .. v.find(";")]
except:
discard
finally:
try: client.close()
except: discard