private string GetText()
{
string resultString = string.Empty;
HttpWebRequest request = HttpWebRequest.CreateHttp("http://www.baidu.com");
request.Method = "GET";
request.BeginGetResponse((IAsyncResult result) =>
{
HttpWebRequest webRequest = result.AsyncState as HttpWebRequest;
HttpWebResponse webResponse = (HttpWebResponse)webRequest.EndGetResponse(result);
Stream streamResult = webResponse.GetResponseStream();
StreamReader reader = new StreamReader(streamResult);
//获取的返回值
resultString = reader.ReadToEnd();
streamResult.Close();
reader.Close();
}, request);
return resultString;
}
相关文章
- 10-27Day9:尝试连接绑定数据与API
- 10-27SpringCloud使用Feign调用其他客户端带参数的接口,传入参数为null或报错status 405 reading IndexService#del(Integer);
- 10-27匕首嵌套嵌套,是否有必要调用inject()?
- 10-27python调用cv2.findContours时报错:ValueError: not enough values to unpack (expected 3, got 2)
- 10-27字符串API—04
- 10-27codeblocks 主函数调用其他文件的函数时报错:"error:undefined reference to xxx"
- 10-27F5 api接口开发实战(一)
- 10-27SIP模块版本错误问题:the sip module implements API v??? but XXX module requires API v???
- 10-27Symbol API
- 10-27GYCTF Web区部分WP