added limits and query for iterating nosteamers through rest endpoint
This commit is contained in:
parent
38bde2b107
commit
23ecc0db5b
@ -1,27 +1,19 @@
|
|||||||
import time
|
import time
|
||||||
import requests
|
import requests
|
||||||
from settings import (get_connection, key)
|
from settings import (get_connection, key)
|
||||||
|
|
||||||
def main():
|
def process_queries(sql_statement):
|
||||||
with get_connection() as conn:
|
with get_connection() as conn:
|
||||||
with conn.cursor() as cur:
|
with conn.cursor() as cur:
|
||||||
sql_statement = """
|
cur.execute(sql_statement)
|
||||||
select *
|
res = cur.fetchall()
|
||||||
from `unloze_anti-spoofing`.sb_bans_shortened sb
|
|
||||||
left outer join `unloze_anti-spoofing`.connect_restriction cr on
|
|
||||||
sb.steam_id = cr.steam_id
|
|
||||||
where cr.asn is null
|
|
||||||
"""
|
|
||||||
cur.execute(sql_statement)
|
|
||||||
res = cur.fetchall()
|
|
||||||
for index, r in enumerate(res):
|
for index, r in enumerate(res):
|
||||||
steam_id = r[0]
|
steam_id = r[0]
|
||||||
ip = r[1]
|
ip = r[1]
|
||||||
url = f"https://proxycheck.io/v2/{ip}?key={key}&asn=1"
|
url = f"https://proxycheck.io/v2/{ip}?key={key}&asn=1"
|
||||||
jrequest = requests.get(url).json()
|
jrequest = requests.get(url).json()
|
||||||
#print(jrequest)
|
|
||||||
d = jrequest[ip]
|
d = jrequest[ip]
|
||||||
try:
|
try:
|
||||||
asn = d["asn"]
|
asn = d["asn"]
|
||||||
provider = d["provider"]
|
provider = d["provider"]
|
||||||
country = d["country"]
|
country = d["country"]
|
||||||
@ -37,8 +29,30 @@ def main():
|
|||||||
"""
|
"""
|
||||||
cur.execute(sql_statement, [country, asn, provider, steam_id, ip])
|
cur.execute(sql_statement, [country, asn, provider, steam_id, ip])
|
||||||
conn.commit()
|
conn.commit()
|
||||||
time.sleep(2.5)
|
time.sleep(2.5)
|
||||||
print(f'at {index + 1}/{len(res)}')
|
print(f'at {index + 1}/{len(res)}')
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
sql_statement = """
|
||||||
|
select sb.steam_id, sb.ipv4
|
||||||
|
from `unloze_anti-spoofing`.sb_bans_shortened sb
|
||||||
|
left outer join `unloze_anti-spoofing`.connect_restriction cr on
|
||||||
|
sb.steam_id = cr.steam_id
|
||||||
|
where cr.asn is null
|
||||||
|
limit 40
|
||||||
|
"""
|
||||||
|
process_queries(sql_statement)
|
||||||
|
sql_statement = """
|
||||||
|
select auth, address
|
||||||
|
from `unloze_anti-spoofing`.connections sb
|
||||||
|
left join `unloze_anti-spoofing`.connect_restriction cr on
|
||||||
|
sb.auth = cr.steam_id and sb.address = cr.ipv4
|
||||||
|
where cr.asn is null
|
||||||
|
and sb.type != 'SteamLegit'
|
||||||
|
limit 950
|
||||||
|
"""
|
||||||
|
process_queries(sql_statement)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user