Je veux me connecter sur youtube en utilisant C#. J'utilise HttpWebRequest. Procédure Je suivais:connexion Youtube en utilisant C#
- charge la page de connexion en utilisant GET et d'analyser la valeur galX nom d'utilisateur
- POST/mot de passe avec galX
- obtenir une page de meta refresh, analyser l'URL et la charge en utilisant GET
- à chaque étape les cookies sont traités à l'aide de CookieContainer
- Les valeurs d'en-tête UserAgent, ContentType etc sont définies et AllowAutoRedirect est true.
maintenant je reçois le code Javascript suivant comme réponse.
var Ga, G = G || {};
G.a = { g: "cookie_missing", f: "cookie_found", h: "gaia_failure" };
var Gb = /\s*;\s*/;
var Gc = function() {
try
{
return new XMLHttpRequest
}
catch (a)
{
for (var b = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"], c = 0; c < b.length; c++)
try
{
return new ActiveXObject(b[c])
}
catch (d) { }
}
return null
},
Gd = function() {
this.d = Gc(); this.b = {}
};
Gd.prototype.oncomplete = function() { };
Gd.prototype.send = function (a) {
var b = [], c;
for (c in this.b) {
var d = this.b[c];
b.push(c + "=" + encodeURIComponent(d))
}
var b = b.join("&"), e = this.d, f = this.oncomplete;
e.open("POST", a, !0);
e.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
e.setRequestHeader("Content-length", "" + b.length);
e.onreadystatechange = function() {
4 == e.readyState && f({ status: e.status, text: e.responseText })
};
e.send(b)
};
Gd.prototype.get = function (a) {
var b = this.oncomplete, c = this.d; c.open("GET", a, !0);
c.onreadystatechange = function() { 4 == c.readyState && b({ status: c.status, text: c.responseText }) };
c.send()
};
var Gf = function (a) {
this.c = a; this.i = this.j();
if (null == this.c) throw new Ge("Empty module name");
};
Ga = Gf.prototype;
Ga.j = function() {
var a = window.location.pathname;
return a && 0 == a.indexOf("/accounts") ? "/accounts/JsRemoteLog" : "/JsRemoteLog"
};
Ga.k = function (a, b, c) {
for (var d = this.i, e = this.c || "", d = d + "?module=" + encodeURIComponent(e), a = a || "", d = d + "&type=" + encodeURIComponent(a), b = b || "", d = d + "&msg=" + encodeURIComponent(b), c = c || [], a = 0; a < c.length; a++) d = d + "&arg=" + encodeURIComponent(c[a]);
try {
var f = Math.floor(1E4 * Math.random()), d = d + "&r=" + ("" + f)
}
catch (g) { }
return d
};
Ga.send = function (a, b, c) {
var d = new Gd; d.b = {};
try {
var e = this.k(a, b, c);
d.get(e)
} catch (f) { }
};
Ga.error = function (a, b) {
this.send("ERROR", a, b)
};
Ga.warn = function (a, b) {
this.send("WARN", a, b)
};
Ga.info = function (a, b) {
this.send("INFO", a, b)
};
Ga.m = function (a) {
var b = this;
return function() {
try {
return a.apply(null, arguments)
}
catch (c) {
throw b.error("Uncatched exception: " + c), c;
}
}
};
var Ge = function() { };
G = G || {};
G.e = G.e || new Gf("report_sid_status");
G.l = function (a, b, c) {
if (window.postMessage && window.parent) {
if (a) {
a:
{
if (document.cookie)
for (var a = b + "=", b = document.cookie.split(Gb), d = 0; d < b.length; d++) {
var e = b[d], e = e.replace(/^\s+/, ""), e = e.replace(/\s+$/, "");
if (0 == e.indexOf(a)) {
a = e.substr(a.length);
break a
}
}
a = null
}
a = null == a ? G.a.g : G.a.f
}
else a = G.a.h; window.parent.postMessage(a, c)
}
};
G_checkSidAndReport = G.e.m(G.l);
G_checkSidAndReport('0', 'SID', 'https:\x2F\x2Faccounts.google.com');
Que faire maintenant? En utilisant cette procédure, je peux me connecter avec succès Gmail mais pas YouTube. Je pense que javascript est posté sur le serveur, mais je suis incapable de comprendre ce qui est en train de poster.
[beaucoup] Ce genre de question a été (http://stackoverflow.com/questions/9336395/login-using-webclient-or-httpwebrequest) [demandé] (http:/(http://stackoverflow.com/questions/3507855/c-sharp-login-examples) [avant] (http://stackoverflow.com/questions/1336310/login-to-web-page-using-c-sharp). –
s'il vous plaît lire la question à nouveau! –