本文整理汇总了C#中HttpGet.SendReqReturnResponseString方法的典型用法代码示例。如果您正苦于以下问题:C# HttpGet.SendReqReturnResponseString方法的具体用法?C# HttpGet.SendReqReturnResponseString怎么用?C# HttpGet.SendReqReturnResponseString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpGet
的用法示例。
在下文中一共展示了HttpGet.SendReqReturnResponseString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button1_Click
private void button1_Click(object sender, EventArgs e)
{
HttpGet get = new HttpGet(string.Format("https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=queryLeftTicket&orderRequest.train_date={0}&orderRequest.from_station_telecode={1}&orderRequest.to_station_telecode={2}&orderRequest.train_no=&trainPassType=QB&trainClass=QB%23D%23Z%23T%23K%23QT%23&includeStudent=00&seatTypeAndNum=&orderRequest.start_time_str=00%3A00--24%3A00",
this.dateTimePicker1.Value.ToString("yyyy-MM-dd"),
this.textBox1.Tag, this.textBox2.Tag));
string temp = string.Format("orderRequest.train_date={0}&orderRequest.from_station_telecode={1}&orderRequest.to_station_telecode={2}&orderRequest.train_no=&trainPassType=QB&trainClass=QB%23D%23Z%23T%23K%23QT%23&includeStudent=00&seatTypeAndNum=&orderRequest.start_time_str=00%3A00--24%3A00",
this.dateTimePicker1.Value.ToString("yyyy-MM-dd"),
this.textBox1.Tag, this.textBox2.Tag);
this.getParams(temp);
string tests = string.Format("https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=queryLeftTicket&orderRequest.train_date={0}&orderRequest.from_station_telecode={1}&orderRequest.to_station_telecode={2}&orderRequest.train_no=&trainPassType=QB&trainClass=QB%23D%23Z%23T%23K%23QT%23&includeStudent=00&seatTypeAndNum=&orderRequest.start_time_str=00%3A00--24%3A00",
this.dateTimePicker1.Value.ToString("yyyy-MM-dd"),
this.textBox1.Tag, this.textBox2.Tag);
get.req.Referer = "https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=init";
get.req.CookieContainer.Add(reqCookies);
string result = get.SendReqReturnResponseString();
//string result = "0,<span id='id_330000K5980K' class='base_txtdiv' onmouseover=javascript:onStopHover('330000K5980K#BXP#WCN') onmouseout='onStopOut()'>K599</span>, 北京西 <br> 05:20, 武昌 <br> 20:37,15:17,--,--,--,--,--,9,4,--,8,<font color='#008800'>有</font>,--,<a name='btn130_2' class='btn130_2' style='text-decoration:none;' onclick=javascript:getSelected('K599#15:17#05:20#330000K5980K#BXP#WCN#20:37#北京西#武昌#08#27#1*****30364*****00091*****00083*****0004#MUFFMDhDQTNCNEMzQjMwMTU4Qzg5NjdDODMxREI2MkNFODFDMThEREM3MzM0NDA5NEY0RTUzMTU6Ojo6MTM4MTMwMTIxMTg2MQ==#C1')>预 订</a>";
result = result.Replace(" ", string.Empty).Replace("<br>", string.Empty).
Replace("<font color='#008800'>", string.Empty).Replace("</font>", string.Empty)
.Replace("<img src='/otsweb/images/tips/first.gif'>", string.Empty)
.Replace("<img src='/otsweb/images/tips/last.gif'>", string.Empty)
.Replace("<font color='darkgray'>", string.Empty);
string para1 = "onStopOut()'>";
string para2 = "</span>";
string[] trains = result.Split(new string[] { "\\n" }, StringSplitOptions.RemoveEmptyEntries);
List<TrainModel> trainList = new List<TrainModel>();
foreach (string item in trains)
{
string[] data = item.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
TrainModel trainmodel = new TrainModel()
{
checi = data[1].Substring(data[1].IndexOf(para1) + para1.Length).Replace(para2, string.Empty),
fazhan = data[2],
tostation = data[3],
lishi = data[4],
shangwu = data[5],
tedeng = data[6],
yideng = data[7],
erdeng = data[8],
gaojiruanwo = data[9],
ruanwo = data[10],
yingwo = data[11],
ruanzuo = data[12],
yingzuo = data[13],
wuzuo = data[14],
qita = data[15],
ordertiket = data[16]
};
trainList.Add(trainmodel);
}
this.dataGridView1.DataSource = trainList;
}
示例2: SavePassenger
public List<Passenger> SavePassenger()
{
HttpGet get = new HttpGet("https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=getpassengerJson");
get.req.CookieContainer.Add(reqCookies);
string json = get.SendReqReturnResponseString();
if (!string.IsNullOrEmpty(json))
{
try
{
passengetList = JsonConvert.DeserializeObject<List<Passenger>>(JObject.Parse(json)["passengerJson"].ToString());
if (passengetList.Count > 0)
{
XDocument xdoc = new XDocument(new XDeclaration("1.0", "utf-8", "yes"));
XElement rootele = new XElement("data");
passengetList.ForEach(x =>
{
XElement city = new XElement("city");
city.SetAttributeValue("first_letter", x.first_letter);
city.SetAttributeValue("isUserSelf", x.isUserSelf);
city.SetAttributeValue("mobile_no", x.mobile_no);
city.SetAttributeValue("old_passenger_id_no", x.old_passenger_id_no);
city.SetAttributeValue("old_passenger_id_type_code", x.old_passenger_id_type_code);
city.SetAttributeValue("old_passenger_name", x.old_passenger_name);
city.SetAttributeValue("passenger_flag", x.passenger_flag);
city.SetAttributeValue("passenger_id_no", x.passenger_id_no);
city.SetAttributeValue("passenger_id_type_code", x.passenger_id_type_code);
city.SetAttributeValue("passenger_id_type_name", x.passenger_id_type_name);
city.SetAttributeValue("passenger_name", x.passenger_name);
city.SetAttributeValue("passenger_type", x.passenger_type);
city.SetAttributeValue("passenger_type_name", x.passenger_type_name);
city.SetAttributeValue("recordCount", x.recordCount);
city.SetValue(x.passenger_name);
rootele.Add(city);
});
xdoc.Add(rootele);
xdoc.Save(passengerXMLPath);
return passengetList;
}
}
catch (Exception ex)
{
return null;
}
}
return null;
}
示例3: GetAccessToken
/// <summary>
/// 获取AccessToken
/// </summary>
/// <returns>返回请求结果JSON字符串,AccessToken需自行根据不同应用进行提取</returns>
public virtual string GetAccessToken(Dictionary<string, string> dic, HttpMethod.RequestMethod method)
{
UriBuilder uri = new UriBuilder(AccessTokenRequestUrl);
string queryString = Common.BuildQueryString(dic);
uri.Query = queryString;
string result = string.Empty;
if (method == HttpMethod.RequestMethod.GET) //GET请求
{
HttpGet get = new HttpGet(uri.ToString());
result = get.SendReqReturnResponseString();
}
else if (method == HttpMethod.RequestMethod.POST) //POST请求
{
HttpPost post = new HttpPost(AccessTokenRequestUrl, queryString);
result = post.SendReqReturnResponseString();
}
return result;
}
示例4: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//Dictionary<string, string> postdic = new Dictionary<string, string>();
List<string> keys = new List<string>();
List<string> values = new List<string>();
SendOrderReqParams postdic = new SendOrderReqParams(keys, values);
postdic.Add("org.apache.struts.taglib.html.TOKEN", token);
postdic.Add("leftTicketStr", leftTicketStr);
postdic.Add("textfield", "中文或拼音首字母");//搜索乘客框value
for (int j = 0; j < this.checkedListBox1.Items.Count; j++)
{
if (checkedListBox1.GetItemChecked(j))
{
postdic.Add("checkbox" + j.ToString(), j.ToString());
}
}
postdic.Add("orderRequest.train_date", queryTicketParams["orderRequest.train_date"]);
postdic.Add("orderRequest.train_no", orderParams["trainno4"]);
postdic.Add("orderRequest.station_train_code", orderParams["station_train_code"]);
postdic.Add("orderRequest.from_station_telecode", queryTicketParams["orderRequest.from_station_telecode"]);
postdic.Add("orderRequest.to_station_telecode", queryTicketParams["orderRequest.to_station_telecode"]);
postdic.Add("orderRequest.seat_type_code", string.Empty);
postdic.Add("orderRequest.ticket_type_order_num", string.Empty);
postdic.Add("orderRequest.bed_level_order_num", "000000000000000000000000000000");
postdic.Add("orderRequest.start_time", orderParams["train_start_time"]);
postdic.Add("orderRequest.end_time", orderParams["arrive_time"]);
postdic.Add("orderRequest.from_station_name", orderParams["from_station_name"]);
postdic.Add("orderRequest.to_station_name", orderParams["to_station_name"]);
postdic.Add("orderRequest.cancel_flag", "1");
postdic.Add("orderRequest.id_mode", "Y");
int passengerCounts = 1;
for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
{
if (i == this.dataGridView1.Rows.Count - 1)
{
continue;
}
Dictionary<string, string> passengetDic = new Dictionary<string, string>();
passengetDic.Add(string.Format("passenger_{0}_seat", passengerCounts), "M");
passengetDic.Add(string.Format("passenger_{0}_ticket", passengerCounts), "1");
passengetDic.Add(string.Format("passenger_{0}_name", passengerCounts), this.dataGridView1.Rows[i].Cells[3].Value.ToString().Trim());
foreach (string key in cardTypeDic.Keys)
{
if (cardTypeDic[key] == this.dataGridView1.Rows[i].Cells[4].Value.ToString())
{
passengetDic.Add(string.Format("passenger_{0}_cardtype", passengerCounts), key);
}
}
passengetDic.Add(string.Format("passenger_{0}_cardno", passengerCounts), this.dataGridView1.Rows[i].Cells[5].Value.ToString().Trim());
passengetDic.Add(string.Format("passenger_{0}_mobileno", passengerCounts), this.dataGridView1.Rows[i].Cells[6].Value.ToString().Trim());
string passengerTickets = string.Format("M,0,1,{0},{1},{2},{3},Y", passengetDic[string.Format("passenger_{0}_name", passengerCounts)]
, passengetDic[string.Format("passenger_{0}_cardtype", passengerCounts)],
passengetDic[string.Format("passenger_{0}_cardno", passengerCounts)],
passengetDic[string.Format("passenger_{0}_mobileno", passengerCounts)]);
string oldPassengers = passengetDic[string.Format("passenger_{0}_name", passengerCounts)] + "," +
passengetDic[string.Format("passenger_{0}_cardtype", passengerCounts)] + "," +
passengetDic[string.Format("passenger_{0}_cardno", passengerCounts)];
postdic.Add("passengerTickets", passengerTickets);
postdic.Add("oldPassengers", oldPassengers);
foreach (string key in passengetDic.Keys)
{
postdic.Add(key, passengetDic[key]);
}
postdic.Add("checkbox9", "Y");
passengerCounts++;
}
for (int k = 0; k < 5 - passengerCounts + 1; k++)
{
postdic.Add("oldPassengers", string.Empty);
postdic.Add("checkbox9", "Y");
}
postdic.Add("randCode", this.textBox1.Text.Trim());
postdic.Add("orderRequest.reserve_flag", "A");
postdic.Add("tFlag", "dc");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < keys.Count; i++)
{
sb.AppendFormat("{0}={1}&", keys[i], values[i]);
}
sb.Remove(sb.ToString().LastIndexOf("&"), 1);
HttpPost post = new HttpPost("https://dynamic.12306.cn/otsweb/order/confirmPassengerAction.do?method=checkOrderInfo&rand=" + this.textBox1.Text + "",
sb.ToString());
post.req.CookieContainer.Add(reqCookies);
string resultstr = post.SendReqReturnResponseString();
if (!string.IsNullOrEmpty(resultstr))
{
JObject json1 = JObject.Parse(resultstr);
if (json1["msg"] != null && !string.IsNullOrEmpty(json1["msg"].Value<string>()))
{
MessageBox.Show(json1["msg"].Value<string>());
return;
//.........这里部分代码省略.........
示例5: button1_Click
private void button1_Click(object sender, EventArgs e)
{
string validateCode = this.textBox1.Text;
string urlPrefix = "https://dynamic.12306.cn";
//获取JS文件
HttpGet get1 = new HttpGet("https://dynamic.12306.cn/otsweb/loginAction.do?method=init");
get1.req.CookieContainer.Add(reqCookies);
string html = get1.SendReqReturnResponseString();
string jsURL = html.Substring(html.IndexOf("/otsweb/dynamicJsAction.do?jsversion="));
jsURL = urlPrefix + jsURL.Substring(0, jsURL.IndexOf("method=loginJs") + "method=loginJs".Length);
//获取JS文件中的 Key
HttpGet get2 = new HttpGet(jsURL);
get2.req.CookieContainer.Add(reqCookies);
string jsContent = get2.SendReqReturnResponseString();
string dynamicKey = jsContent.Substring(jsContent.IndexOf("function gc()"));
int beginIndex = dynamicKey.IndexOf("key='") + "key='".Length;
dynamicKey = dynamicKey.Substring(beginIndex, dynamicKey.IndexOf("';") - beginIndex);
//调用加密JS方法 得到加密的value
string encryptValue = this.webBrowser1.Document.InvokeScript("finalEncrypt", new object[] { dynamicKey, "1111" }).ToString();
//得到loginRand,refundfLag,
HttpGet get3 = new HttpGet("https://dynamic.12306.cn/otsweb/loginAction.do?method=loginAysnSuggest");
get3.req.CookieContainer.Add(reqCookies);
string loginParam = get3.SendReqReturnResponseString();
string loginRand = loginParam.Substring(loginParam.IndexOf(":\"") + 2);
loginRand = loginRand.Substring(0, loginRand.IndexOf("\","));
string tempStr = "randError\":\"";
string randError = loginParam.Substring(loginParam.IndexOf(tempStr) + tempStr.Length, 1);
Dictionary<string, string> loginDic = new Dictionary<string, string>();
loginDic.Add("loginRand", loginRand);
loginDic.Add("refundLogin", "N");
loginDic.Add("refundFlag", randError);
loginDic.Add("isClick", "");
loginDic.Add("form_tk", "null");
loginDic.Add("loginUser.user_name", this.textBox2.Text);
loginDic.Add("nameErrorFocus", "");
loginDic.Add("user.password", this.textBox3.Text);
loginDic.Add("passwordErrorFocus", "");
loginDic.Add("randCode", validateCode);
loginDic.Add("randErrorFocus", "");
loginDic.Add(HttpUtility.UrlEncode(dynamicKey), HttpUtility.UrlEncode(encryptValue));
loginDic.Add("myversion", "undefined");
string postdata = string.Empty;
List<string> strs = new List<string>();
foreach (string item in loginDic.Keys)
{
strs.Add(string.Format("{0}={1}", item, loginDic[item]));
}
postdata = string.Join("&", strs);
HttpPost post = new HttpPost("https://dynamic.12306.cn/otsweb/loginAction.do?method=login", postdata);
post.req.Referer = "https://dynamic.12306.cn/otsweb/loginAction.do?method=init";
post.req.CookieContainer.Add(reqCookies);
string loginResult = post.SendReqReturnResponseString();
string[] error = new string[] { "密码输入错误,您还有3次机会!", "请输入正确的验证码!", "登录名不存在!" };
if (!loginResult.Contains("欢迎您登录中国铁路客户服务中心网站"))
{
for (int i = 0; i < error.Length; i++)
{
if (loginResult.Contains(error[i]))
{
GenerateValidateCode();
MessageBox.Show(error[i]);
}
}
}
else
{
order order = new Winform.order();
order.reqCookies = reqCookies;
order.dynamicKey = dynamicKey;
order.dynamicValue = encryptValue;
order.Show();
}
}