instagram-scrap-2/listuser.py

66 lines
2.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import json
import os
import math
i=0
target_classes = ['seo-web','برنامه_نویسی']
onlineShops=set()
users=set()
for file in os.listdir('.'):
for target_class in target_classes:
if target_class in file and 'users' not in file:
try:
f = open(file,'r')
jsondata = json.loads(f.read())
for cm in jsondata:
# print(cm['text'])
is_online_shop=False
username =username=cm['user']['username']
target_words = ['seo','web','programming']
# target_words =["sh0p","keratin","collection","beeauty","makeup","hairsalon","design","lift","nail","galerry","accessory","skin","skiin","skincaare","shoop","style","market","beauti","vitrin","art","badalijat",'store','shop',"arayesh","beauty","cosmetic","perfume","zibae","zibai","skincare","gallery"]
# target_words =["brauty","arayesh","shop"]
for target_word in target_words:
if target_word in username:
i+=1
onlineShops.add(username)
is_online_shop=True
if is_online_shop == False:
users.add(username)
except:
pass # print(f"https://instagram.com/{username}")
print(len(users))
print(len(onlineShops))
f2 = open("seo-web-focused.txt","a")
f3 = open("users-seo-web.txt","a")
f3.truncate(0)
f2.truncate(0)
for user in sorted(onlineShops):
f2.write(f"@{user}\n")
for user in users:
f3.write(f"@{user}\n")
# b=0
# filenumber = 1
# fl = open(f"users-list-seo-web-{str(filenumber)}.txt","a")
# for user in sorted(users):
# fl.write(f"https://instagram.com/{user}\n")
# b+=1
# if (b == 5):
# filenumber+=1
# b=0
# fl = open(f"users-list-seo-web-{str(filenumber)}.txt","a")
# fl = open(f"users-list-{target_class}.txt","a",encoding="utf-8")
# fl.truncate(0)
# for user in users:
# fl.write(f"@{user}\n")
# b+=1
# if b % 5 ==0:
# fl.write(f"نگاهتون رو به این محتوا دعوت میکنم")
# fl.write(f"\n------------------------------------------------\n")