开发者

How can I parse 'document.getElementById' values in Cocoa?

开发者 https://www.devze.com 2023-02-07 22:27 出处:网络
I\'m having a hard time to figure out how to get the value from the below code. document.getElementById(\'today-details-1\').value = \'41\';

I'm having a hard time to figure out how to get the value from the below code.

document.getElementById('today-details-1').value = '41';
document.getElementById('today-details-2').value = '30';

I'm having my application making a NSURLConnection and it is receiving the contents of the page which are basically 5 more lines like the ones above.

I want to be able to get开发者_JAVA百科 the value for each of the elements. How would I accomplish this?

I tried nodesForXPath but can't get that to work as this is not really a xml page.


Maybe something like this:

NSString *oneString = [myWebView stringByEvaluatingJavaScriptFromString:@"document.getElementById('today-details-1').value"];


For parsing HTML look at this previously asked question which has a number of good solutions.

I used hpple which is suggested in an answer

0

精彩评论

暂无评论...
验证码 换一张
取 消