Fetch Web HTML data in tvOS - html

I have an iOS app where I read the data from the website in a UIWebView which is hidden from the user (don't worry its my own website), parse the data from the resulting HTML, read specific info and put it into NSArrays to display in UITable. All is well and good and works in iOS.
- (void)webViewDidFinishLoad:(UIWebView *)webView2
{
NSLog(#"webViewDidFinishLoad ...");
NSString *htmlSourceCodeStr = [webView2 stringByEvaluatingJavaScriptFromString:#"document.documentElement.outerHTML"];
}
I was thinking of porting the same app to tvOS. Surprise Surprise UIWebView isn't available in tvOS.
Is there a way for me to load / Fetch website data somehow in tvOS, parse and read the resulting HTML? Is that even possible?

Just make the HTTP request directly using NSURLSession. You'll get the HTML back as NSData and can parse it from there just like before. You should probably do the same in your iOS app: if you're not going to show the HTML to the user then there's no point in using something as heavyweight as a web view.

To answer your question, no (kind of), it is not possible at the moment. The link you posted pretty much answered your question - there may be a way using private APIs or using UIWebViews (maybe), but Apple would never allow it to be published. Not only that, but WebKit isn't available either. This pretty much sums it up:
Companies hoping to leverage a universal HTML5/CSS/JS-based UI for multiple platforms may no longer find this option viable. They will need to rethink their strategy for providing a cohesive branded experience on multiple platforms while still writing native apps for those platforms. That’s not to say that someone wouldn’t be able to try compiling WebKit and creating their own view within to render HTML. Certainly there are companies with the manpower and resources to do this. I’m not certain those apps wouldn’t get rejected, though.
Very sorry I couldn't give you the answer you were looking for. Good luck :)
Sources
https://developer.apple.com/library/tvos/releasenotes/General/tvOS90APIDiffs/index.html
https://medium.com/bpxl-craft/apple-tv-a-world-without-webkit-5c428a64a6dd#.s2h3xvsx6
Web app in tvOS
http://www.idownloadblog.com/2015/11/06/apple-tv-browser-hack/

Related

Determine the UI library that a particular website is using

I am starting to build my own website using the Django framework. It has become apparent that in order to make quick progress I will have to use some form of external library to handle most of my HTML/CSS/Javascript, for example, https://materializecss.com
I have begun investigating different websites to see what works and what doesn't and I was wondering if there is a quick way to identify what UI library a particular website is using.
Chrome's 'inspect' tool doesn't really help me because I get lost with so much HTML.
For example, this website https://www.moneyunder30.com/category/banking apparently uses https://materializecss.com, is there a general place hidden deep in the HTML where I could look to find this information?
Thanks
There's a pretty cool Chrome extension called Wappalyzer

Web browser interface using HTML/CSS/JS?

I’m building a simple browser, and I’d like to code most of it using HTML/JS/CSS. I cannot use iframes to display pages, due to frame-busting. What are my options?
The browser is not meant to be production-quality, but as a proof-of-concept for my thesis, similar to this interactive mockup. The main features it will need to support are:
Loading any page without frame-busting (even google.com),
Detecting when a link is clicked and opening it in a new frame, with the original one remaining intact.
I intend to write this using Web technologies, but it’s OK if it needs to be wrapped up in a small amount of something else, e.g., to turn it into an Android app. However, if it’s possible, it would be best if I could load the app as a web page. Finally, it is also preferable to be able to run the app on an Android device, but it’s OK if it only works on a desktop.
In researching this question, I came across a few options:
<iframe>. Google.com doesn't load at all in an iframe. I tried using the sandbox attribute, but it still didn’t load. Is there a way around this (for any page)?
Mozilla’s Browser API. This API was supposed to allow you to use the mozbrowser attribute in an iframe when building FirefoxOS apps. I suspect there’s no longer any way to access it. I couldn’t get the sample browser app loaded, and it seems that mozbrowser is not supported in WebExtensions. Did I miss something? Is there a way to make this work?
<webview> in a Chrome app. This is the only option that worked so far. I was able to download and install the sample browser app in Chrome. The one downside is that it seems to be Chrome-only (and I would prefer cross-platform or Firefox, all else being equal). Are there any issues with this option? Any way to make it run without Chrome?
Electron app with <webview>. While the setup here is more complicated than the previous option, it seems like the code would be very similar (there’s even a similar sample browser app). Are there any advantages/disadvantages to this option over the previous?
So, are there ways to make options 1 or 2 work? Are there perhaps other options?
HTML/CSS is a "language" translated by the browser into pages. You cannot code a browser in HTML. The easiest solution is to code it in C#.
I'm not sure if this is a good solution, but you can try Electron (nodeJS). You will only need to use JS/CSS/HTML.

ExtJs and Sencha Touch Search Engine Optimization

I've started learning ExtJS 4 and Sencha Touch 2, and i really like it.
The main difference between Sencha products and jQuery(& others) is that instead of enhancing preexisting HTML, it generates its own DOM based on objects created in JavaScript.
Apps developed like this are great as intranet apps, but can you create a consumer oriented website using Sencha?(like an online store)
I see that you don't write any HTML code in ExtJS or Sencha Touch so i am wondering how can fully generated Javascript page be indexed by Search Engines like Google. As i know, the Google Bot only sees the plain HTML code.
Is there anyway to SEO a Sencha WebApp?
Kind Regards,
Dan Cearnau
Nothing is impossible. You just need to do some work.
1. Generate standard static page using PHP or smth else. The page should look like the page of your ExtJS app. But all links must have GET params in URL. Also PHP should aggregate input GET params.
2. Add your ExtJS app to the page. In the app you have to take into an account GET params and make proper request.
2a. If a real user opens your page: PHP generates the output, then ExtJS app starts and hides the static page and generates the dynamic output.
2b. If a crawler opens your page so JS is disabled, PHP aggregates the request according to GET params and generates the output.
You can add params to URL like #param1&param2&param3 in ExtJS when clicking on links, so real users will be able to share their links. Just learn the router on PHP-side to understand URLs like this.
There is no way to make SEO-friendly pages using JavaScript only.
Using a full blown app it would be close to impossible to SEO. They are far too dynamic. Search engines work of indexing pages. They can deal with some Ajax stuff by supporting pages with #s but imagine how many pages a fully functional app will have. Every view you have has 100s of options that would constitute a new page, which also has 100s of options. All these virtual pages would most likely be just slight variations from other pages. different sort order, different filter, moved panel, search option.
If you use ExtJs to enhance a website like jQuery is often used, then that's a different story. You will have html for the spiders to read and then you enhance how the content works via javascript (see progressive enhancement).
Actually in Touch 2 you can define paths and use history support. This will treat sections of your app as actual pages in the browser w/ standard functionality like going back in the browser etc... this will be your best bet when working with mobile SEO
Getting any kind of SEO out of a Sencha app is impossible since it builds everything on the fly. Even if you use the history support in Sencha Touch, thats also done on the fly and has no effect on SEO.
For consumer-facing websites, Sencha is not the answer. For back-end (for maybe managing the shopping cart), its a different story.

Android: How do I retrieve problematic data from a specific webpage?

I have used .NET and ShDocVw for years to grab data off webpages without any issues I couldn't overcome. This website has me beat though. It seems like such as easy task to grab the titles and other information off a library search page, but I can't see the data to be able to grab it. Usually, I just look in the DOM, but the data wasn't there. I did a view source, but the data wasn't there. I am so confused.
I am learning Android right now and that is how I would like to solve my problem, but if .NET would be easier... Right now I will take any help, in any form.
The URL is http://catalog.kcls.org/opac/en-US/skin/kcls/xml/rresult.xml?if=&it=h&bl=&lf=&a=&la=&cl=&d=1&l=1&s=pubdate&sd=desc&adt=ml&tp=&t=bibcn%3ADVD%20FIC%20ON%20ORDER&av=&rt=multi
For this specific website, if you disable javascript in your browser, you will see they give you a link to a plain html search portal
http://catalog.kcls.org/opac/en-US/extras/slimpac/start.html

How can I save a webpage as an image in my rails app?

In my rails app I have a need to save some webpages and display them to the user as images. For example, how would I save www.google.com as an image?
There is a command line utility called CutyCapt that is using the WebKit-Rendering engine to render HTML-Pages into various image formats. Maybe this is for you?
http://cutycapt.sourceforge.net/
Prohibitively difficult to do in pure Ruby, so you'd want to use an external service for this. Browsershots does it, for example, and it looks like they have an api, although I haven't used it myself. Maybe someone else can chime in with alternative but similar services.
You'll also want to read up on delayed_job or something similar, to make sure you're accessing those page images as a background task and that it doesn't interfere with your actual application.
You can't do it easily (probably can't do it at all).
Each page is just a text - html data. The view you want to make an image of is a rendered page. Browser renders the page using tonns of techniques like html parsing, javascript parsing, css parsing, font rendering, etc.. To make the screenshot of google page - you would need to do all the rendering somewhere in memory and then take a screenshot of rendered page.
That task is almost impossible (there is nothing fully impossible).
If you are really eager to donate tonns of time to accomplish that task - you should do this steps:
1) Find some opensource rendering engine. Firefox would do.
2) Find some way to communicate between ruby-on-rails and that engine.
3) Wire it all together and see the results.
However, I see steps 1 and 2 as nearly impossible.
Firefox addon:
https://addons.mozilla.org/en-US/firefox/addon/1146/