【发布时间】:2017-03-26 15:14:01
【问题描述】:
string locationName = Console.ReadLine();
string url = "https://www.google.com/#q=latitude+and+longitude+" + locationName;
HtmlWeb web = new HtmlWeb();
HtmlDocument doc = web.Load(url);
HtmlNode rateNode = doc.DocumentNode.SelectSingleNode("//div[@class='_XWk']");
string res = rateNode.InnerText;
Console.WriteLine(res);
我正在使用上面的代码从 google 获取某个位置,并将显示纬度和经度的文本框复制到字符串 res 中。每次运行代码时,我都会收到 nullReferenceException。
我怎样才能把字符串分成两个只有坐标的字符串?
String res = "34.0522° N, 118.2437° W" 转换为 String res1 = "34.0522" 和 String res2 = "118.2437"
提前致谢
【问题讨论】:
标签: c# html string web html-agility-pack