本文整理汇总了C#中System.Net.WebClient.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# System.Net.WebClient.IndexOf方法的具体用法?C# System.Net.WebClient.IndexOf怎么用?C# System.Net.WebClient.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.WebClient
的用法示例。
在下文中一共展示了System.Net.WebClient.IndexOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSSQResult
/// <summary>
/// 获取双色球开奖结果
/// </summary>
/// <returns></returns>
private void GetSSQResult()
{
string ssqResult = "";
try
{
System.Threading.Thread.Sleep(3000);
string html = new System.Net.WebClient().DownloadString("http://www.zhcw.com/kaijiang/index_kj.html");
html = html.Substring(html.IndexOf("<dd>"), html.IndexOf("</dd>") - html.IndexOf("<dd>") + 4).Replace("\r\n","");
string regStr = "<li class=\"qiured\">(.*?)</li> <li class=\"qiured\">(.*?)</li> <li class=\"qiured\">(.*?)</li> <li class=\"qiured\">(.*?)</li> <li class=\"qiured\">(.*?)</li> <li class=\"qiured\">(.*?)</li> <li class=\"qiublud\">(.*?)</li>";
var regex = new System.Text.RegularExpressions.Regex(regStr);
System.Text.RegularExpressions.Match m;
if ((m = regex.Match(html)).Success && m.Groups.Count == 8)
{
for (int i = 1; i < 8; i++)
{
ssqResult += "," + m.Groups[i].Value;
}
ssqResult = ssqResult.Substring(1);
}
}
catch (Exception ex)
{
ssqResult = ex.Message;
}
Response.Write(ssqResult);
Response.Flush();
Response.End();
}
示例2: time_token
private string time_token(string port)
{
byte retry = 0;
string str = "";
while (str == "")
{
try
{
str = new System.Net.WebClient().DownloadString("http://chat.uchat.co.kr:" + port + "/socket.io/1/?t=" + ((new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond).Ticks - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks) / 10000L).ToString());
}
catch { System.Threading.Thread.Sleep(1000); if(++retry == 10) throw new Exception("토큰을 받아올 수 없습니다. (시도횟수 10) - time_token()"); }
}
return str.Substring(0, str.IndexOf(":"));
}