instagram用户检查器

问题描述 投票:1回答:2
print(os.linesep)
tag=input("your username here : ")



instagram ='https://www.instagram.com/'
x=requests.get(instagram+tag)
if x.status_code == 200:
  print("Instagram found: "+tag)
else:
    print("not found")

如何使instagram检查器打开一个文本文件并检查每个用户是否可用?

python instagram
2个回答
1
投票

我会将您要检查的用户名放入文本文件,然后使用for loop读取该文本文件以进行每次名称检查(如果可用)。>>

例如

with open('names.txt', 'r') as f:
     lines = f.readlines()
     for name in lines:
        checkInstagram(name)

我建议使用checkInstagram函数,因为它会使代码看起来更加整洁。

编辑

我添加了一些代码,将打开Instagram页面,这是使用webbrowser模块import webbrowser完成的>

代码:webbrowser.open(f'{instagram+tag}', new=2)

如果需要,请使用它,但希望对您有所帮助

尽管我很确定您很快就会遇到一些速率限制,并且您可能违反了Instagram的使用条款,但我还是会这样:

usernames_to_check = ['bandup1', 'bandup2', 'bandup3']
with open('outfile.txt', 'w') as outfile:
    for username in usernames_to_check:
        x = requests.get(instagram + tag)
        if x.status_code == 200:
            outfile.write(f"Instagram found: {tag}\n")
        else:
            outfile.write(f"not found: {tag}\n")

0
投票

尽管我很确定您很快就会遇到一些速率限制,并且您可能违反了Instagram的使用条款,但我还是会这样:

© www.soinside.com 2019 - 2024. All rights reserved.