Ответы пользователя по тегу Парсинг
  • Авторизация Instagram без API?

    @slavabars
    Веб программист
    Отправляешь пост запрос вида username=ИМЯ&password=ПАРОЛЬ на https://instagram.com/accounts/login/ajax/ и сохраняешь куки. С этими куками ходишь по сайту.

    function curl_file($url, $cookie = 'coockie', $post = '', $xhr = '') {
    	$ch = curl_init();
    	curl_setopt($ch, CURLOPT_URL, $url);
    	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    	curl_setopt($ch, CURLOPT_HEADER, true);
    	curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    	curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
    	curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
    	curl_setopt($ch, CURLOPT_REFERER, $url);
    	curl_setopt($ch, CURLOPT_AUTOREFERER, true);
    	if ($post) {
    		curl_setopt($ch, CURLOPT_POST, true);
    		curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
    	}
    	if ($xhr) {
    		preg_match('|csrftoken(.*)|', file_get_contents('coockie'), $csrf);
    		curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-CSRFToken:' . trim($csrf[1]), 'X-Instagram-AJAX:1', 'X-Requested-With:XMLHttpRequest'));
    	}
    	$file = curl_exec($ch);
    	curl_close($ch);
    	return $file;
    }
    
    curl_file('https://instagram.com/accounts/login/ajax/', 'coockie', 'username=Имя&password=Пароль', 1);
    echo curl_file('https://instagram.com/', 'coockie', 0, 1); //Выйдет твоя страничка


    Ну а далее гуляем с куками по сайту
    Ответ написан
    6 комментариев