Once I get past that, I can use the following code to clip out just the data I need. Print(NSString(data: data!, encoding: NSUTF8StringEncoding))īut while I can print it, I can't seem to get the NSString data into a Swift string.
![website data extractor online website data extractor online](https://i.ytimg.com/vi/SKBkclf1FxA/maxresdefault.jpg)
The code in my first post nicely prints these couple lines to the console, and the numerical result I need is in the printed output So the "page" I need to extract the data from is much smaller, just a couple lines of text. I've since learned that the data I need can be accessed by directly linking to a servlet in a browser, see here for instance. Well I've gotten a lot closer but I'm still struggling.
#WEBSITE DATA EXTRACTOR ONLINE HOW TO#
PS: in the example of how to inject a script, they used "Wikipedia" as an example site, so you can search for that on the asciiwwdc2014 site to find sessions that used that term. In the end I was able to get a form listener installed, so when a user logged in I could determine the email address used. I don't know JavaScript so this was a real PITA. In brief, you use a WKWebView (and perhaps you can make it invisible or offscreen), you tell it to connect to a URL, at some point you add your own script, then when the page has loaded, you invoke your script, which posts back some data.
![website data extractor online website data extractor online](https://i1.wp.com/www.2basetechnologies.com/wp-content/uploads/2017/11/10-Best-Web-Scraping-Tools-to-Extract-Online-Data-thumb.jpg)
In the end I froze the video (or slide) and did a screen print to access the otherwise unavailable source code. One the WWDC 2014 sessions covered this topic, I believe it was "Introducing the Modern WebKit API". This is all terribly complicated (for me it was), and daunting as there are few examples to go by. You script can call one of the existing scripts, and return a value to you in a "post back" message. If the web page has scripts, its possible for you to inject your own script into the downloaded page, then call it.