红色字替换您需要的信息。
//获取最近三天天气情况
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> ");
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;
}
}