how to capture data from a webresponse/streamreader and write it back in console?












0















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++;
}









share|improve this question

























  • 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 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
















0















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++;
}









share|improve this question

























  • 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 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














0












0








0








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++;
}









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 26 '18 at 2:22









Gabriel Luci

10.8k11424




10.8k11424










asked Nov 26 '18 at 1:30









Michael FoxMichael Fox

11




11













  • 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 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 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 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 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












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
});


}
});














draft saved

draft discarded


















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
















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)