如何使浏览器登录,并做一些事情,然后重新登录使用其他帐户 [英] How to make the browser login and do something then re-login with another account

查看:155
本文介绍了如何使浏览器登录,并做一些事情,然后重新登录使用其他帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的程序,我可以打开一个网页,我粘贴TextBox1的用户名和密码

I have a simple program that i can open a webpage and i paste the user name and password from textbox1

然后做里面的东西,一个想重新登录使用其他帐户后,

then do something inside, after that a want to re-login with another account

我可以拖做到三个账户把我想处理一个开放的多个用户名

i can do it for tow or three accounts put i want to deal with an open number of usernames

我想从多行TextBox采取用户名

在code粘贴只有第一线和通字,然后点击OK是:

the code to paste only the first line and the pass word and click ok is:

TextReader read = new StringReader(textBox2.Text);
int rows = 500;

string[] text1 = new string[rows];
for (int r = 1; r < rows; r++)
{    
    text1[r] = read.ReadLine();
    // textBox3.Text = text1[r];

    HtmlElement ele = webBrowser1.Document.GetElementById("name"); if (ele != null)
    ele.InnerText = text1[r];

    ele = webBrowser1.Document.GetElementById("password"); if (ele != null)
    ele.InnerText = text1[r] + "5";

    ele = webBrowser1.Document.GetElementById("s1"); if (ele != null)
    ele.InvokeMember("click");

文本1 [R] 表示,将采取公正的第一行

text1[r] means that it will take the just the first line

现在程序里面,然后用这个code注销

now the program is inside then logout with this code

webbrowser1.navigate("http://example.com/logout.php");

然后我要重新登录并做第二行(另一账户)同放那么第三个等等。我该怎么办呢?

then i want to re login and do the same put with the second line (another account) then the third etc. How can i do it?

推荐答案

这完全不是那么回事那样的。你需要做的是表现得像浏览器,即提交表单:

It doesn't quite work like that. What you need to do is behave like the browsers, namely, submit the form:

  • How do you programmatically fill in a form and 'POST' a web page?
  • How to submit http form using C#

您将不得不学习POST请求的结构,并建立与应用程序类似的职位要求。你将不得不使用像萤火调查系统产生的网络流量,当你提交表单和重复POST请求。看看这个问题太: HTTP表单后变更提交数据

You will have to study the structure of the POST request and build a similar post request with your application. You'll have to use something like FireBug to investigate the network traffic that's generated when you submit the form and duplicate the POST request. Take a look at this question too: http form post change submit data

这篇关于如何使浏览器登录,并做一些事情,然后重新登录使用其他帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆