自己做成web service public static String[] GetSongerPhoto(string songerName) { if (String.IsNullOrEmpty(songerName)) { return new string[0]; } string url = "http://images.google.com/images?q={0}&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&ie=UTF-8&sa=N&hl=zh-CN&tab=wi"; url = string.Format(url, System.Web.HttpUtility.UrlEncode(songerName)); WebClient web = new WebClient(); string body = web.DownloadString(url); Regex re = new Regex(@"http://[^""]+.jpg", RegexOptions.IgnoreCase); List<String> slist = new List<string>(); foreach (Match m in re.Matches(body)) { slist.Add(m.Value); } return slist.ToArray(); } public static void DoTest() { foreach (String s in GetSongerPhoto("张学友")) { Console.WriteLine(s); } }
你的意思是不是觉得这跟方法不可取啊!
我没法子了,呵呵!
其实是可以用web客户端模拟request,然后获取response,分析内容。 比如谷歌音乐就有歌手库,那里能找到歌手的数据。---太麻烦了。想找个捷径
---要是有个websevice免费提供一个接口 ~。~ 哈哈哈!那多好啊! 想太多了。
这个咋办呢!
public static String[] GetSongerPhoto(string songerName)
{
if (String.IsNullOrEmpty(songerName))
{
return new string[0];
}
string url = "http://images.google.com/images?q={0}&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a&um=1&ie=UTF-8&sa=N&hl=zh-CN&tab=wi";
url = string.Format(url, System.Web.HttpUtility.UrlEncode(songerName));
WebClient web = new WebClient();
string body = web.DownloadString(url);
Regex re = new Regex(@"http://[^""]+.jpg", RegexOptions.IgnoreCase);
List<String> slist = new List<string>();
foreach (Match m in re.Matches(body))
{
slist.Add(m.Value);
}
return slist.ToArray();
}
public static void DoTest()
{
foreach (String s in GetSongerPhoto("张学友"))
{
Console.WriteLine(s);
}
}