저는 스크래핑 스크립트를 사용하여 소규모 프로젝트를 진행하고 있습니다.
로그인을 시도 중이에요https://www.plusdede.com/login, 숫자 인증코드를 이용한 간편 로그인입니다. 중요한 코드는 다음과 같습니다.
<div class="page-login">
<h3 class="text-center">Login</h3>
<form method="POST" action="https://www.plusdede.com/login" accept-charset="UTF-8" class="form-horizontal"><input name="_token" type="hidden" value="fU1zoQ4Ewm2xMiS3UXIZ6w3bMBBMV7Dz8xT6fLQD">
<div class="form-group ">
<div class="col-xs-12">
<input id="input-email" class="form-control" placeholder="Email o usuario" name="email" type="text"> </div>
</div>
<div class="form-group">
<div class="col-xs-12">
<input name="password" class="form-control" type="password" placeholder="Password">
</div>
</div>
<div class="form-group captcha">
<div class="col-xs-12">
<img src="https://www.plusdede.com/captcha/flat?tkmGJHuB" alt="captcha">
</div>
</div>
<div class="form-group captcha">
<div class="col-xs-12"></div>
<div class="col-sm-3"><label for="input-captcha" for="input-captcha" class="control-label">Captcha:</label></div>
<div class="col-sm-9"><input id="input-captcha" class="form-control" placeholder="Escribe los números de la imagen" name="captcha" type="number" value=""></div>
</div>
<div class="form-group text-center">
<div class="col-xs-12">
<button class="btn btn-success" type="submit">Entrar</button>
</div>
</div>
</form>
</div>
내 스크립트에서 다음 코드를 사용합니다.
#!/bin/bash
usuario=*******
pass=********
uagent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
encoding='accept-encoding: gzip, deflate, br'
languaje='accept-language: es-ES,es;q=0.8,en;q=0.6'
n_requests='upgrade-insecure-requests: 1'
accept='accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8'
cache_control='cache-control: max-age=0'
authority='authority: www.plusdede.com'
wget https://www.plusdede.com/login
curl --cookie-jar cjar --output /dev/null -H "$encoding" -H "$languaje" -H "$n_requests" -H "$uagent" -H "$cache_control" -H "$authority" https://www.plusdede.com/login
line_captcha=$(grep -i "/captcha/" login)
url_captcha=$(echo "$line_captcha" | cut -d "\"" -f 2)
wget "$url_captcha" -O captcha.png
read -p "Introducir catpcha: " cod;
line_clave=$(grep -i "form method=" login)
token=$(echo "$line_clave" | cut -d "\"" -f 14)
curl -b cjar -c cjar -H "$encoding" -H "$languaje" -H "$n_requests" -H "$uagent" -H "$cache_control" -H "$authority" --form "_token=$token" --form "email=$usuario" --form "password=$pass" --form "captcha=$cod" --location --output ./inicio.html https://www.plusdede.com/login --trace-ascii trace.txt
echo "Datos del log: "
echo "$token"
echo "$usuario"
echo "$pass"
echo "$clave"
POST에서 오류를 찾기 위해 추적을 사용했지만 아무 것도 표시되지 않았습니다. 데이터는 정확했지만 서버에 "inicio.html"을 요청하면 매번 오류가 발생했습니다.