私はC#を使用してYouTubeにログインしたいです。私はHttpWebRequestを使用しています。私は、次の午前 手順: C#を使用してYouTubeのログイン
- 負荷ログインページGALX値をGETを使用して解析し
- 、メタリフレッシュページを取得 をGET使用して、URLと負荷を解析
- はCookieContainerを使用して処理されます。
- UserAgent、ContentTypeなどのヘッダー値が設定され、AllowAutoRedirectがtrueです。
私は応答として次のJavascriptコードを取得しています。
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');
ここで何をしますか?この手順を使用すると、Gmailにログインできますが、YouTubeにはログインできません。私はjavascriptがサーバーに投稿していると思うが、実際に何が投稿されているのか分からない。
質問のこの種がされている[頼ま](http://stackoverflow.com/questions/9336395/login-using-webclient-or-httpwebrequest)[たくさん](のhttp:/ /stackoverflow.com/questions/6069302/how-would-i-programatically-login-to-a-site-such-as-codeproject-or-stackoverflow)[times](http://stackoverflow.com/questions/3507855)/c-sharp-login-examples)[前](http://stackoverflow.com/questions/1336310/login-to-web-page-using-c-sharp)を参照してください。 –
もう一度質問をお読みください! –