我一直在尝试从WP8的webbrowser获取元标签信息,但没有成功。WP8 - 从WebBrowser获取元标签信息
我tryed:
var myDesc = (string)myBrowser.InvokeScript("eval", " $('meta[name=description]').attr('content');");
这...
string jsString = "";
jsString += " var metas = document.getElementsByTagName('meta'); ";
jsString += " var data = 'test'; ";
jsString += " var mLen = metas.length; ";
jsString += " for(var i=0;i<mLen;i++){ ";
jsString += " if(metas[i].getAttribute('name').toLowerCase() == 'description'){ ";
jsString += " data = metas[i].getAttribute('content'); ";
jsString += " } ";
jsString += " } ";
myBrowser.InvokeScript("eval", new string[] { jsString });
var myDesc = (string)myBrowser.InvokeScript("eval", "data;");
这...
myBrowser.InvokeScript("eval", new string[] { "var desc = document.getElementsByName('description')[0].getAttribute('content');" });
,并与所有的错误处理:
{System.SystemException: An unknown error has occurred. Error: 80020101. at Microsoft.Phone.Controls.NativeMethods.ValidateHResult(Int32 hr) at Microsoft.Phone.Controls.WebBrowserInterop.InvokeScript(String scriptName, String[] args) at Microsoft.Phone.Controls.WebBrowser.InvokeScript(String scriptName, String[] args) ...
有人可以帮助我吗?
最好的问候!
同样的错误: {System.SystemException:发生未知错误。错误:80020101. at Microsoft.Phone.Controls.NativeMethods.ValidateHResult(Int32 hr) at Microsoft.Phone.Controls.WebBrowserInterop.InvokeScript(String scriptName,String [] args) at Microsoft.Phone.Controls.WebBrowser.InvokeScript (String scriptName,String [] args) at xxxxxxxx.myBrowser_LoadCompleted ... –
@GabrielGómez';;}在脚本中删除一个; ...我可以得到meta的正确信息。 – AlexisXu
不!同样的错误... :( –