mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 22:59:31 +00:00
Detect suspended accounts
This commit is contained in:
parent
240ce15651
commit
8a6978cf74
8 changed files with 38 additions and 6 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import asyncdispatch, strutils, uri
|
||||
import asyncdispatch, strutils, uri, httpclient, json, xmltree, htmlparser
|
||||
|
||||
import ".."/[types, parser]
|
||||
import utils, consts, media
|
||||
|
|
@ -7,11 +7,21 @@ proc getTweet*(username, id, after, agent: string): Future[Conversation] {.async
|
|||
let
|
||||
headers = genHeaders({
|
||||
"pragma": "no-cache",
|
||||
"x-previous-page-name": "profile"
|
||||
"x-previous-page-name": "profile",
|
||||
"accept": htmlAccept
|
||||
}, agent, base, xml=true)
|
||||
|
||||
url = base / username / tweetUrl / id ? {"max_position": after}
|
||||
html = await fetchHtml(url, headers)
|
||||
|
||||
newClient()
|
||||
var html: XmlNode
|
||||
try:
|
||||
let resp = await client.get($url)
|
||||
if resp.code == Http403 and "suspended" in (await resp.body):
|
||||
return Conversation(tweet: Tweet(tombstone: "User has been suspended"))
|
||||
html = parseHtml(await resp.body)
|
||||
except:
|
||||
discard
|
||||
|
||||
if html == nil: return
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue