how to capture data from a webresponse/streamreader and write it back in console?
I created a web request with post data then getting a response telling me if it contained something, and my question is on how to also capture something else from the response and write that in the console. Do I have to create a separate GET request? and how would i do that, and how do you get something from the get request and write that into the console.
https://imgur.com/JA0k1HJ
try
{
WebResponse webResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Program.logincookie = cookieContainer;
StreamReader streamReader = new StreamReader(webResponse.GetResponseStream());
string text4 = streamReader.ReadToEnd();
streamReader.Close();
webResponse.Close();
if (!text4.Contains("Invalid username/password."))
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("[HIT] " + email + ":" + password);
File.AppendAllText("hits.txt", email + ":" + password + Environment.NewLine);
Valid++;
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[BAD] " + email + ":" + password);
Invalid++;
}
}
catch (Exception)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("[BAD] " + email + ":" + password);
Invalid++;
}
c# webrequest webresponse
|
show 13 more comments
I created a web request with post data then getting a response telling me if it contained something, and my question is on how to also capture something else from the response and write that in the console. Do I have to create a separate GET request? and how would i do that, and how do you get something from the get request and write that into the console.
https://imgur.com/JA0k1HJ
try
{
WebResponse webResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Program.logincookie = cookieContainer;
StreamReader streamReader = new StreamReader(webResponse.GetResponseStream());
string text4 = streamReader.ReadToEnd();
streamReader.Close();
webResponse.Close();
if (!text4.Contains("Invalid username/password."))
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("[HIT] " + email + ":" + password);
File.AppendAllText("hits.txt", email + ":" + password + Environment.NewLine);
Valid++;
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[BAD] " + email + ":" + password);
Invalid++;
}
}
catch (Exception)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("[BAD] " + email + ":" + password);
Invalid++;
}
c# webrequest webresponse
You mean likeConsole.WriteLine(text4)
?
– Gabriel Luci
Nov 26 '18 at 1:35
No, like get something and write it FROM the webresponse.
– Michael Fox
Nov 26 '18 at 1:40
I don't understand what you mean. You want to read a specific part of the response?
– Gabriel Luci
Nov 26 '18 at 1:41
You already read the whole response. I want to take something from the response and write it in the console using Console.WriteLine
– Michael Fox
Nov 26 '18 at 1:45
You have the whole response in astring
calledtext4
. So you can do whatever you want with it now. It depends what you want from it. Use any of theString
methods (likeSubstring()
) and take what you want from it.
– Gabriel Luci
Nov 26 '18 at 1:54
|
show 13 more comments
I created a web request with post data then getting a response telling me if it contained something, and my question is on how to also capture something else from the response and write that in the console. Do I have to create a separate GET request? and how would i do that, and how do you get something from the get request and write that into the console.
https://imgur.com/JA0k1HJ
try
{
WebResponse webResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Program.logincookie = cookieContainer;
StreamReader streamReader = new StreamReader(webResponse.GetResponseStream());
string text4 = streamReader.ReadToEnd();
streamReader.Close();
webResponse.Close();
if (!text4.Contains("Invalid username/password."))
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("[HIT] " + email + ":" + password);
File.AppendAllText("hits.txt", email + ":" + password + Environment.NewLine);
Valid++;
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[BAD] " + email + ":" + password);
Invalid++;
}
}
catch (Exception)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("[BAD] " + email + ":" + password);
Invalid++;
}
c# webrequest webresponse
I created a web request with post data then getting a response telling me if it contained something, and my question is on how to also capture something else from the response and write that in the console. Do I have to create a separate GET request? and how would i do that, and how do you get something from the get request and write that into the console.
https://imgur.com/JA0k1HJ
try
{
WebResponse webResponse = (HttpWebResponse)httpWebRequest.GetResponse();
Program.logincookie = cookieContainer;
StreamReader streamReader = new StreamReader(webResponse.GetResponseStream());
string text4 = streamReader.ReadToEnd();
streamReader.Close();
webResponse.Close();
if (!text4.Contains("Invalid username/password."))
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("[HIT] " + email + ":" + password);
File.AppendAllText("hits.txt", email + ":" + password + Environment.NewLine);
Valid++;
}
else
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("[BAD] " + email + ":" + password);
Invalid++;
}
}
catch (Exception)
{
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("[BAD] " + email + ":" + password);
Invalid++;
}
c# webrequest webresponse
c# webrequest webresponse
edited Nov 26 '18 at 2:22
Gabriel Luci
11.5k11525
11.5k11525
asked Nov 26 '18 at 1:30
Michael FoxMichael Fox
11
11
You mean likeConsole.WriteLine(text4)
?
– Gabriel Luci
Nov 26 '18 at 1:35
No, like get something and write it FROM the webresponse.
– Michael Fox
Nov 26 '18 at 1:40
I don't understand what you mean. You want to read a specific part of the response?
– Gabriel Luci
Nov 26 '18 at 1:41
You already read the whole response. I want to take something from the response and write it in the console using Console.WriteLine
– Michael Fox
Nov 26 '18 at 1:45
You have the whole response in astring
calledtext4
. So you can do whatever you want with it now. It depends what you want from it. Use any of theString
methods (likeSubstring()
) and take what you want from it.
– Gabriel Luci
Nov 26 '18 at 1:54
|
show 13 more comments
You mean likeConsole.WriteLine(text4)
?
– Gabriel Luci
Nov 26 '18 at 1:35
No, like get something and write it FROM the webresponse.
– Michael Fox
Nov 26 '18 at 1:40
I don't understand what you mean. You want to read a specific part of the response?
– Gabriel Luci
Nov 26 '18 at 1:41
You already read the whole response. I want to take something from the response and write it in the console using Console.WriteLine
– Michael Fox
Nov 26 '18 at 1:45
You have the whole response in astring
calledtext4
. So you can do whatever you want with it now. It depends what you want from it. Use any of theString
methods (likeSubstring()
) and take what you want from it.
– Gabriel Luci
Nov 26 '18 at 1:54
You mean like
Console.WriteLine(text4)
?– Gabriel Luci
Nov 26 '18 at 1:35
You mean like
Console.WriteLine(text4)
?– Gabriel Luci
Nov 26 '18 at 1:35
No, like get something and write it FROM the webresponse.
– Michael Fox
Nov 26 '18 at 1:40
No, like get something and write it FROM the webresponse.
– Michael Fox
Nov 26 '18 at 1:40
I don't understand what you mean. You want to read a specific part of the response?
– Gabriel Luci
Nov 26 '18 at 1:41
I don't understand what you mean. You want to read a specific part of the response?
– Gabriel Luci
Nov 26 '18 at 1:41
You already read the whole response. I want to take something from the response and write it in the console using Console.WriteLine
– Michael Fox
Nov 26 '18 at 1:45
You already read the whole response. I want to take something from the response and write it in the console using Console.WriteLine
– Michael Fox
Nov 26 '18 at 1:45
You have the whole response in a
string
called text4
. So you can do whatever you want with it now. It depends what you want from it. Use any of the String
methods (like Substring()
) and take what you want from it.– Gabriel Luci
Nov 26 '18 at 1:54
You have the whole response in a
string
called text4
. So you can do whatever you want with it now. It depends what you want from it. Use any of the String
methods (like Substring()
) and take what you want from it.– Gabriel Luci
Nov 26 '18 at 1:54
|
show 13 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53473706%2fhow-to-capture-data-from-a-webresponse-streamreader-and-write-it-back-in-console%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53473706%2fhow-to-capture-data-from-a-webresponse-streamreader-and-write-it-back-in-console%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You mean like
Console.WriteLine(text4)
?– Gabriel Luci
Nov 26 '18 at 1:35
No, like get something and write it FROM the webresponse.
– Michael Fox
Nov 26 '18 at 1:40
I don't understand what you mean. You want to read a specific part of the response?
– Gabriel Luci
Nov 26 '18 at 1:41
You already read the whole response. I want to take something from the response and write it in the console using Console.WriteLine
– Michael Fox
Nov 26 '18 at 1:45
You have the whole response in a
string
calledtext4
. So you can do whatever you want with it now. It depends what you want from it. Use any of theString
methods (likeSubstring()
) and take what you want from it.– Gabriel Luci
Nov 26 '18 at 1:54