Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
pip install gestures, WKWebView, UI animations and more
-
@mikael
oh I see, I usually use r_string in py, so I didn't notice \' in doc_string
now it works fine
thanks for help -
hi, im back again :D
we know that some browser has non-pic mode (i dont know right name,just like that mean), is it possible to add that feature to wkwebview? for some reason, i just need the full html content (dom-tree maybe?) -
@Anxietier, if you mean ”Reader Mode”, WKWebView does not include it. But you can use a SafariViewController, see @cvp’s code around the middle of this thread.
-
If you just want to parse the HTML, use
requests
. Unless you need JavaScript to run I guess.@mikael isn't there a delegate that would let you filter by uri? I forget if the should_load_uri or whatever gets called for <img>'s -- in which case he could just return false for non-html urls.
-
@JonB, no it does not. Would be good to understand the need a bit more before trying to bend WKWebView to it. For the most part, just fetching the page with requests, then filtering imgs and javascript before giving it to WKwebView might work just as well.
-
@JonB
yeah i need js in script tag to run. some requests is not easy to fake them you know, so i was wandering if i can let webview run in 'read mode' to simulate 'selenium', cause some imgs spend many data traffic, and i dont wanna take double traffic for one img -
@mikael
thanks, it is helpful, i would try to understand them. -
@Anxietier, if web scraping is your thing, then the SafariViewController will not help you. WKWebView is the best tool around for Pythonista, as far as I know.
-
@Anxietier, hey, there’s something called content rules that can be configured to just stop loading images, see here. I will give it a try a bit later.
-
@mikael
well, theres an open source android app names 'H-viewer', using regex&selector to select out imgs, and re-layout them, so that we can just watch imgs. also, theres an app in appstore names 'yealico', it has similar function.
I was trying to fake(reproduce?) that by python in ista, I found one way to do that, 'use two wkwebviews, only present one, the other one load url in background, when it did finish load, use js selector to get imgs url, then show imgs on presented webview', im not sure will background-webview cost data-usage, but I dont want to cost double 'img data-usage' -
@Anxietier, the content rules, which might help or not, require at least two completion blocks, doable but unfortunately I do not have the kind of time I had earlier to spend on these projects.
I would be happy to provide background support if you want to give it a go. I would expect it to be mostly versions of code already used in this component.
-
@mikael
sorry for reply late, im not sure if i get your point at sec paragraph, cause my eng not even good and machine translation not so reliable.
let me assume you meant that you would give support if i want to try adding read-mode.
thanks for your kind, but i dont know if i have time to do it, and i didnt learn objc before, so maybe it would take long time to finish that (or never :/
btw, content rule is a great direction indeed, i should take some time to learn about that