PDA

Ver la Versión Completa : Validar sesión en formulario


Rolo
31-08-2007, 21:53:58
Les cuento, un amiguete también teclas quiere hacerse un programa parecido al que pusieron ustedes para coger los enlaces de algunos sitios de video como youtube, flickr, pornotube y otros, me ha dicho que ya tiene varios pero este último le da problemas, al margen de la temática dudosa del sitio resulta curioso a modo técnico que para llegar al enlace del video antes hay que pasar una especie de filtro formulario que en apariencia tiene pocos campos: bMonth, bDay, bYear, verifyAge, submit, y le pregunta al usuario la fecha de nacimiento para asegurarse de que tiene 18 años o más y así poder entrar. El programa en teoría tiene que hacer lo mismo que un usuario, superar este formulario pasándole esos datos de manera aleatoria, sin embargo en el último campo pusieron CONTINUE », carácter que por lo visto equivale a %BB.

Después de intentar hasta yo mismo pasarle la cadena transformada al sitio durante un buen rato, hasta con referers y cookies por si los empleaba para validar parece que no hay manera de engañarle. Googleando di con este enlace (http://www.arrakis.es/%7Erggi3/pornotube-dl/pornotube-dl) de alguien que hizo algo similar en perl y parece funcionar, además mete %C2%BB como equivalente del caracter unicode » (http://www.fileformat.info/info/unicode/char/00bb/index.htm)

A ver si el maestro Seoane que ayudó en lo de flickr o alguien que controle del tema, sabe como se puede solucionar el tema con este formulario y el caracter unicode de marras en delphi, nunca había visto algo parecido :eek:

Grasias por anticipado :D

xEsk
13-09-2007, 16:03:26
Para poder "emular" la validación debes enviar los parámetro por POST. Los parámetro a pasar por POST son: bMonth=01&bDay=1&bYear=1970&verifyAge=true&submit=CONTINUE »

Aquí te pongo un trozo del código que realiza la validación y obtiene el HTML de una página (piensa que el código que te muestro esta hecho usando Synapse para Internet...).

// start a custom http instance
HTTP:=THTTPSend.Create;
try
// set the POST parameters
WriteStrToStream(HTTP.Document, 'bMonth=01&bDay=1&bYear=1970&verifyAge=true&submit=CONTINUE »');
// Set the Mime Type
HTTP.MimeType := 'application/x-www-form-urlencoded';
// Get the page html (send it as POST)
HTTP.HTTPMethod('POST', 'http://www.pornotube.com/media.php?m=1389132');
// if all is ok
if HTTP.ResultCode = 200 then
begin
// Aqui ya podemos analizar el código HTML de la pagina! :D
// HTTP.Document --> contiene el HTML de la pagina
end;
finally
HTTP.Free;
end;
Y aquí el código exacto que uso en el xVideoServiceThief (http://sourceforge.net/projects/xviservicethief) para obtener la URL del video FLV en PornoTube (añadido hoy, y disponible en la próxima actualización):
function TVideoDownload_PornoTube.GetVideoInformation(
const URL: String): TVideoDownloadInfo;
const
AGE_VALIDATION = 'bMonth=01&bDay=1&bYear=1970&verifyAge=true&submit=CONTINUE »';
GET_FLV_INFO_URL = 'http://www.pornotube.com/player/player.php?%s';
GET_FLV_URL = 'http://%s.pornotube.com/%s/%s.flv';

var
Html: TStringList;
HTTP: THTTPSend;
VideoID: String;
FlvID: String;
FUserID: String;
FDomain: String;

begin
// clear possible prev. data
InitTVideoDownloadInfo(Result);
// start a custom http instance
HTTP:=THTTPSend.Create;
try
// set the POST parameters
WriteStrToStream(HTTP.Document, AGE_VALIDATION);
// Set the Mime Type
HTTP.MimeType := 'application/x-www-form-urlencoded';
// Get the page html (send it as POST)
HTTP.HTTPMethod('POST', URL);
// if all is ok
if HTTP.ResultCode = 200 then
begin
Html:=TStringList.Create;
try
// get the html
Html.LoadFromStream(HTTP.Document);
// get the video Title
Result.Title:=CopyBetween(Html.Text, '<title>PornoTube.com - ', '</title>');
Result.Title:=Copy(Result.Title, 1, Pos(' - Browsing: Videos -', Result.Title) - 1);
// get the video ID
VideoID:=CopyBetween(Html.Text, 'player/v.swf?v=', '"');
// get the video Information
HTTP.Clear;
HTTP.HTTPMethod('GET', Format(GET_FLV_INFO_URL, [VideoID]));
if HTTP.ResultCode = 200 then
begin
// get the html
Html.LoadFromStream(HTTP.Document);
// get the video ID
FlvID:=CopyBetween(Html.Text, 'mediaId=', '&');
// get the User ID
FUserID:=CopyBetween(Html.Text, 'userId=', '&');
// get the video domain
FDomain:=CopyBetween(Html.Text, 'mediaDomain=', '&');
// get the final FLV url
Result.VideoURL:=Format(GET_FLV_URL, [FDomain, FUserID, FlvID]);
// clear and get the final flv url
Result.VideoURL:=URLtoAscii(Result.VideoURL);
end;
finally
Html.Free;
end;
end;
finally
HTTP.Free;
end;
end;
Saludos.

Rolo
13-09-2007, 17:01:25
Muchísimas gracias xEsk :)

BlackDaemon
26-09-2007, 20:45:12
Después de intentar hasta yo mismo pasarle la cadena transformada al sitio durante un buen rato, hasta con referers y cookies por si los empleaba para validar parece que no hay manera de engañarle. Googleando di con este enlace (http://www.arrakis.es/%7Erggi3/pornotube-dl/pornotube-dl) de alguien que hizo algo similar en perl y parece funcionar, además mete %C2%BB como equivalente del caracter unicode &raquo; (http://www.fileformat.info/info/unicode/char/00bb/index.htm)

Solo una correción, NO esta en "perl" esta en python

saludos!