I'm loading blog posts from a SQL database into a UIWebView. The posts aren't rendering correctly. I went into the database. The data does have html tags, but not <html> <body>
Do I have to inject these tags to get data to render?
The docs state that UIWebView can display "HTML content", by which I assume it means valid HTML content.
I would ensure that the HTML document you are trying to display is able to display in Safari or some other browser.
Note, as suggested in Apple's UIWebView doc that since iOS 8, WKWebView is preferred for new development:
NOTE
In apps that run in iOS 8 and later, use the WKWebView class instead
of using UIWebView. Additionally, consider setting the WKPreferences
property javaScriptEnabled to NO if you render files that are not
supposed to run JavaScript.
Related
I'm trying to scrape an Instagram page using SwiftSoup, but when I run let html = try String(contentsOf: URL("https://www.instagram.com/sasawpi/"), I get back a bunch of JS functions and CSS styles like this, probably because Instagram uses React and some package control to send files over from the server. My question is, can I render it as an HTML DOM, like a browser would, and get it as a text inside of SwiftUI using SwiftSoup or some other library. WebView renders web pages so one of my suggestions was to render it with WebView but I don't know how to get this HTML DOM as text from WebView either.
I want to do the below two tasks In Windows Phone 7 application.
1.Navigate to a web page (e.g.http://www.FlightsInd.com) and get the HTML page data.I wnat to ensure that all the Document data is completely downloaded.
In C#.Net i am doing this using below code:
WebBrowser objWB = new WebBrowser();
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
objWB.Navigate("http://www.FlightsInd.com")
here once the DocumentCompleted event is fired it means all the data in that request is downloaded.
2.Parse HTML page elements data.
In C#.Net i am doing this using below code.
doc = webBrowser1.Document;
btnElem = doc.GetElementById(streleid);
Can anyody help me with the equivalent classes/code for the above two implementations ?
Use WebBrowser Windows Phone control
To Navigate to your page
browser.Navigate(new Uri("http://www.FlightsInd.com"));
To understand that navigation completed and content is loaded
WebBrowser.Navigated Event
WebBrowser.LoadCompleted Event - Occurs after the WebBrowser control has loaded content.
WebBrowser.NavigationFailed Event - to track navigation failures
The WebBrowser class events are raised in the following order: Navigating, Navigated, and LoadCompleted.
To get Html source
WebBrowser Windows Phone control contains special function to save the source for the HTML content currently displayed in WebBrowser control as a string:
string html = browser.SaveToString();
To parse Html
Look at HTML Agility Pack
What is the best way to parse html in C#?
Parsing HTML String
PS. Alternatively you can use webBrowser.InvokeScript (C#) with combination of js eval to invoke any js command which can use window.external.notify inside it to pass results back to C#.
If I get your question right, you can use web browser isBusy property to track if its still downloading data and sleep while its still busy.
For parsing html document you can use NSoup library to parse the html just like jQuery. Its a port from java's JSoup library.
http://www.developerfusion.com/project/98472/nsoup/
Syntax explained here:
http://jsoup.org/cookbook/extracting-data/selector-syntax
If you own the webpage you are navigating to, you can use window.external.notify(document.documentElement.innerHTML) in your javascript to pass the document html to native layer. Then you would catch the value in your native code using ScriptNotify.
A little more complex, but if you don't own the webpage, you could host your own webpage, open an iframe with the original page, and get the html from the iframe.
See here for more info on window.external.notify: http://msdn.microsoft.com/en-us/library/system.windows.controls.webbrowser.scriptnotify(v=vs.95).aspx
I need to launch IE from my WP7 app and load the HTML to create the page dynamically. The HTML is read from a web service and can change at any time, so I'm not able to just store the HTML in a file. Is there a way to do this -- much like you do with WebBrowser.NavigateToString(strHtml)?
-Thanks!
If you are attempting to open your HTML content in an embedded WebBrowser control you can use the "NavigateToString" function and pass it the HTML content you would like to load.
If you are trying to open it in the native IE browser on the device then I would recommend putting state information in the URL and opening the page directly with any parameters required to replicate the view in the browser via the WebBrowserTask. This way you wouldn't technically be opening the HTML code from your app but you would be able to ensure that the HTML content loaded from your service is correct based on your query parameters.
Are you looking for WebBrowserTask?
I want to create a Firefox Extension which will display a webpage. It will be like user should write a something in browser like "about:" or even a button would do ?
How can i load the WebPage in Firefox. The user should have a feel that a webpage is being loaded.
PS: I have javascript and CSS in that Page.
If i cannot make then what changes do i need to make in the web page for that change.
I also want to connect to a server and fetch XML data and want to display process that data and and display it on the page. I am developing this extension as my page is static and HTML/Javascript does not allow cross domain queries. I hope that cross-domain queries are possible if i use extension.
There is Browser XUL object that acts a an standalone browser. You can load any document inside that.
Im unsure of how to approach this, should I have the html to be loaded hidden or load it from somewhere? I want to load a form in one page, and dynamic content on other pages.
The form can be saved to mongo db, and when the page loads should load the data into that form from mongo db.
Where does the html live for all the pages? I want to have a clean html5 document with lets say a content div. all content goes into that block.
Server running Django
Im want to use backbone.js for the app
any help would be appreciated
The initial page should include the basic layout of the application (header, content, sidebar, different placeholder for your views, etc.)
Then you load the application (usually with a controller) and render the different view that will replace the placeholders you had in your layout.
To render the views, I suggest to use a templating engine. With backbone.js there is already underscore.js on the page, so you can use the templating engine included (http://documentcloud.github.com/underscore/#template). You then have to load the template on the page. The easiest way is to create include a script element on the page with your template inside:
<script type="text/template" name="template1">
your template here...
</script>
And you can load it using this:
var template = _.template( jQuery("script[name=template1]").text() )
and execute with your data
var html = template(model)
You build your page with different backbone views using different template.
I hope that help!