1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > c# 调用Google查询天气 手机所属地 农历转换公历

c# 调用Google查询天气 手机所属地 农历转换公历

时间:2019-06-21 04:18:48

相关推荐

c# 调用Google查询天气 手机所属地  农历转换公历

红色字替换您需要的信息。

//获取最近三天天气情况

string url = string.Format("/search?hl=zh-CN&q=tq{0}&meta=&aq=f&oq=", HttpUtility.UrlEncode("上海", System.Text.Encoding.UTF8).ToUpper());

byte[] bytes = new .WebClient().DownloadData(url);

string html = System.Text.Encoding.Default.GetString(bytes);

int a = html.IndexOf("<div class=e>");

if (a > 0)

{

a += 13;

int b = html.IndexOf("<h2 class=hd>", a);

if (b > a)

{

Response.Write(html.Substring(a - 13, b - a + 13).Replace("src=/"/", "src=/"/"));

return;

}

}

//第一种:获取手机号所属地

string url = string.Format("/search?hl=zh-CN&q={0}&aq=f&oq=", "手机号");

byte[] bytes = new .WebClient().DownloadData(url);

string html = System.Text.Encoding.Default.GetString(bytes);

int a = html.IndexOf("<div class=rbt>");

if (a > 0)

{

a += 15;

int b = html.IndexOf("<li class=g>", a);

if (b > a)

{

Response.Write(html.Substring(a - 15, b - a + 15).Replace("src=/"/", "src=/"/").Replace("href=/"/url", "href=/"/url"));

return;

}

}

/// 第二种:无标题页四川 南充 - 中国联通

string url = string.Format("/search?hl=zh-CN&q={0}&aq=f&oq=", "13281906391");

byte[] bytes = new .WebClient().DownloadData(url);

string html = System.Text.Encoding.Default.GetString(bytes);

int a = html.IndexOf("归属地查询</a></h3>&nbsp;");

if (a > 0)

{

a += 20;

int b = html.IndexOf("<div style=/"margin:2px 0/">", a);

if (b > a)

{

Response.Write(html.Substring(a, b - a));

return;

}

}

//农历转换公历

string url = string.Format("/search?hl=zh-CN&q={0}&aq=f&oq=", HttpUtility.UrlEncode("nl1981-6-5", System.Text.Encoding.UTF8).ToUpper());

byte[] bytes = new .WebClient().DownloadData(url);

string html = System.Text.Encoding.Default.GetString(bytes);

int a = html.IndexOf("<div class=e>");

if (a > 0)

{

a += 13;

int b = html.IndexOf("</table></table></div></div>", a);

if (b > a)

{

Response.Write(html.Substring(a - 13, b - a + 29).Replace("src=/"/", "src=/"/"));

return;

}

}

//通过sogou查询IP地址

string url = string.Format("/web?query={0}&ast=&asf=&w=&num=&p=&dp=", "123.112.11.60");

byte[] bytes = new .WebClient().DownloadData(url);

string html = System.Text.Encoding.Default.GetString(bytes);

int a = html.IndexOf("<p class=/"ff/">");

if (a > 0)

{

a += 14;

int b = html.IndexOf("</p>", a);

if (b > a)

{

Response.Write(html.Substring(a - 14, b - a + 14));

return;

}

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。