Objective C - UIWebview to load only a certain part of the webpage?

百般思念 提交于 2020-01-24 10:07:05

问题


I am working with a UIWebview, is there anyway I can just load just the body of a webpage instead of the entire webpage with my UIWebView (aka not load the header and footer)? This website is not mine. But looking at the HTML of this site, I only want to load to div id="mainContent" to /div Either by writing some objective c or javascript?

Thanks! Alan


回答1:


With Web-Kit you can parse the incoming HTML and do whatever you like to it (within, legal rights to the site you are reading)

Once the data is loaded in you can then push the edited HTML to the WKView fairly easily.

If you have an outlet to the webView you can do: (For example a UIWebView in iOS)

[webView loadHTMLString:htmlString baseURL:nil];
[webView setNeedsDisplay];


来源:https://stackoverflow.com/questions/9780700/objective-c-uiwebview-to-load-only-a-certain-part-of-the-webpage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!