该脚本从“帐户”文件中获取一长串instagram用户名,并检查它们是否存在。
我想找到一种使用此脚本的方法,但是当它从列表中进行检查时,它会使用回显“ ERR”或“ OK”将其写入日志文件,(在作为要检查的帐户进行检查时,一定要这样做列表很长,应该运行几天)
而不是直接从instagram检查,它将使用此api
https://username-availability.herokuapp.com/check/instagram/USERNAMEHERE
它应该从accounts文件夹中获取用户名,然后针对此api尝试使用该用户名。使用“状态”行上的响应,如果有帐户,则打印200;否则,则打印404。在这里可以保存“ USERNAMEHERE-Err!”。或“ USERNAMEHERE-好!”到日志文件。
我只需要帮助就可以确定从哪里开始。这可能很复杂,如果可以,抱歉
$content = file_get_contents(__DIR__.'/accounts');
$accounts = explode("\n", $content);
$accounts = array_filter(array_unique($accounts));
if(empty($accounts)){
echo("Add accounts to file 'accounts', each in a new line.\n");
}
foreach($accounts as $account){
if(check($account)){
echo "$account - OK!\n";
}else{
echo "$account - ERR!\n";
}
//sleep(1); // in seconds
}
function check($username){
$url = "https://www.instagram.com/{$username}/";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_HEADER, true);
//curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36');
$c = curl_exec($ch);
//print_r(curl_getinfo($ch));
//print_r($c);
if(curl_getinfo($ch, CURLINFO_HTTP_CODE) === 404){
return true;
}
return false;
}