如何使用自己的asp.net页面接取一个网站吗? [英] How to acess a website using own asp.net page?

查看:143
本文介绍了如何使用自己的asp.net页面接取一个网站吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里想打电话给另一个网站的网址,登录到它,并用我的asp.net项目中使用它的功能之一。我工作在asp.net中的一个项目,我的基于Web的程序会发送短信到手机上。因为我不想向任何网关或类似的,我发现这个网站:

I here want to call another website url, login into it, and use one of its function using my asp.net project. I'm working on a project in asp.net where my web based program will send sms to mobile phones. Since I don't want to subscribe to any gateways or similar, I found this website:

http://sms80.com

现在我想要做的是,从我的asp.net页面我需要访问这个网站,登录并使用其服务,而这一切都必须做在我的asp.net页面编程隐藏。

Now what I want to do is, from my asp.net page I need to access this website, login and use its service but all this must be done hidden programatically in my asp.net page.

我不知是检查网站的元素,如登录名文本框和密码文本框。我不是黑客,但我只需要知道这个过程中,我在该网站做的(我登录使用我的帐户,然后写我的留言,写移动NUM和发送)programaticallyin我的asp.net。

I somehow inspected that websites element such as login name textbox and password textbox. I am not trying to hacking but I just need know the process I do in that website( I login using my account, then write my message and write the mobile num and send) programaticallyin my asp.net.

我做了一些研究,发现我可以发送或URL传递值直如:

I did some research and found out that I can send or pass values in url straight such as:

your_url.aspx?your_url_variable=" + @variable_from_form

但它似乎没有工作。这是任何其他的方式来做到这一点?

but it doesn't seem work. Is it any other way to do it?

推荐答案

如果其他网站没有一个API登录电子进去编程并不是一个简单的过程。

If the other website doesn't have an API loging into it programmatically is not a simple process.

它需要很多的你想怎么的网站登录作品探索性工作和分析。该过程包括首先确定什么是在请求/响应通信后的数据发送用的工具,如提琴手

It requires a lot of exploratory work and analysis of how the website you're trying to login works. The process consists of first determining what is being sent in the request/response communication post data with a tool such as Fiddler.

然后,你需要构建一系列GET和使用任何的 HttpWebRequest的 / HttpWebResponse 类或 WebClient的类,所以你可以模仿浏览器的方式。

Then, you need to construct a series of GETs and POSTs using either HttpWebRequest/HttpWebResponse classes or WebClient class so you can mimic the way the browser does it.

一个例子是:

string url = "http://sms80.com";
HttpWebRequest http = (HttpWebRequest)WebRequest.Create(url);
http.CookieContainer = _cookieJar;
http.Connection = "Keep-alive";
http.Method = "POST";
http.ContentType = "application/x-www-form-urlencoded";
string postData="username=" + username + "&password=" + password;
byte[] dataBytes = UTF8Encoding.UTF8.GetBytes(postData);
http.ContentLength = dataBytes.Length;
Stream postStream = http.GetRequestStream();
postStream.Write(dataBytes, 0, dataBytes.Length);
postStream.Close();
// see if we're logged in
HttpWebResponse httpResponse = (HttpWebResponse)http.GetResponse();
// continue (read the response etc.)

这篇关于如何使用自己的asp.net页面接取一个网站吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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