mirror of
https://github.com/FutaGuard/LowTechFilter.git
synced 2025-06-21 05:21:02 +08:00
Merge pull request #100 from FutaGuard/refactor/workflow-tw165
Refactor workflow
This commit is contained in:
commit
bfed1163ba
@ -23,6 +23,7 @@ def main():
|
||||
r_json = r.json()['result']['records']
|
||||
except (JSONDecodeError, KeyError):
|
||||
logger.critical('Parse JSON Err')
|
||||
raise
|
||||
|
||||
# check if file exists
|
||||
filename = 'TW165.txt'
|
||||
@ -34,16 +35,18 @@ def main():
|
||||
|
||||
with open(filename, 'r') as f:
|
||||
read_ = f.read().splitlines()
|
||||
for row in r_json[1:]:
|
||||
domain = urlparse('http://'+row['WEBURL']).hostname
|
||||
if domain not in read_:
|
||||
added_list.append(domain)
|
||||
|
||||
with open(filename, 'a+') as f:
|
||||
f.write('\n')
|
||||
f.write(
|
||||
'\n'.join(e for e in added_list)
|
||||
)
|
||||
current_domains = frozenset(read_)
|
||||
for row in r_json[1:]:
|
||||
domain = urlparse('http://'+row['WEBURL']).hostname
|
||||
if domain not in current_domains:
|
||||
added_list.append(domain)
|
||||
|
||||
if added_list:
|
||||
with open(filename, 'a+') as f:
|
||||
f.write('\n')
|
||||
f.write(
|
||||
'\n'.join(e for e in added_list)
|
||||
)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Loading…
x
Reference in New Issue
Block a user