How to tell when UIWebView content changes?
up vote
0
down vote
favorite
I am working on an iOS App using Xcode. The app refreshes a UIWebView every X number of seconds.
By way of background, the app is called 'Browser Auto Refresh': https://itunes.apple.com/us/app/browser-auto-refresh/id1177883066?mt=8).
I am trying to implement an alert when the content of the UIWebView changes post a page refresh (i.e. the page currently being refreshed has just been updated by the owner of that page). I have managed to get hold of the response headers but cannot see any eTag info from multiple sites (incl Google.com).
Does anyone know how you can tell that the content of a webpage has changed when refreshing a UIWebView page?
ios uiwebview page-refresh etag
add a comment |
up vote
0
down vote
favorite
I am working on an iOS App using Xcode. The app refreshes a UIWebView every X number of seconds.
By way of background, the app is called 'Browser Auto Refresh': https://itunes.apple.com/us/app/browser-auto-refresh/id1177883066?mt=8).
I am trying to implement an alert when the content of the UIWebView changes post a page refresh (i.e. the page currently being refreshed has just been updated by the owner of that page). I have managed to get hold of the response headers but cannot see any eTag info from multiple sites (incl Google.com).
Does anyone know how you can tell that the content of a webpage has changed when refreshing a UIWebView page?
ios uiwebview page-refresh etag
2
If the web pages displayed in the view are not under your control then each will have different setup (headers, caching, etc.) making IMO virtually impossible to observe the change in bullet proof way. Can you generate a checksum of the html page (data itself) on each load and compare "current" vs "new"?
– Peter Pajchl
Nov 22 at 13:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am working on an iOS App using Xcode. The app refreshes a UIWebView every X number of seconds.
By way of background, the app is called 'Browser Auto Refresh': https://itunes.apple.com/us/app/browser-auto-refresh/id1177883066?mt=8).
I am trying to implement an alert when the content of the UIWebView changes post a page refresh (i.e. the page currently being refreshed has just been updated by the owner of that page). I have managed to get hold of the response headers but cannot see any eTag info from multiple sites (incl Google.com).
Does anyone know how you can tell that the content of a webpage has changed when refreshing a UIWebView page?
ios uiwebview page-refresh etag
I am working on an iOS App using Xcode. The app refreshes a UIWebView every X number of seconds.
By way of background, the app is called 'Browser Auto Refresh': https://itunes.apple.com/us/app/browser-auto-refresh/id1177883066?mt=8).
I am trying to implement an alert when the content of the UIWebView changes post a page refresh (i.e. the page currently being refreshed has just been updated by the owner of that page). I have managed to get hold of the response headers but cannot see any eTag info from multiple sites (incl Google.com).
Does anyone know how you can tell that the content of a webpage has changed when refreshing a UIWebView page?
ios uiwebview page-refresh etag
ios uiwebview page-refresh etag
edited Nov 23 at 10:52
Rengers
7,72512343
7,72512343
asked Nov 22 at 12:43
Charlie Seligman
2,20523160
2,20523160
2
If the web pages displayed in the view are not under your control then each will have different setup (headers, caching, etc.) making IMO virtually impossible to observe the change in bullet proof way. Can you generate a checksum of the html page (data itself) on each load and compare "current" vs "new"?
– Peter Pajchl
Nov 22 at 13:20
add a comment |
2
If the web pages displayed in the view are not under your control then each will have different setup (headers, caching, etc.) making IMO virtually impossible to observe the change in bullet proof way. Can you generate a checksum of the html page (data itself) on each load and compare "current" vs "new"?
– Peter Pajchl
Nov 22 at 13:20
2
2
If the web pages displayed in the view are not under your control then each will have different setup (headers, caching, etc.) making IMO virtually impossible to observe the change in bullet proof way. Can you generate a checksum of the html page (data itself) on each load and compare "current" vs "new"?
– Peter Pajchl
Nov 22 at 13:20
If the web pages displayed in the view are not under your control then each will have different setup (headers, caching, etc.) making IMO virtually impossible to observe the change in bullet proof way. Can you generate a checksum of the html page (data itself) on each load and compare "current" vs "new"?
– Peter Pajchl
Nov 22 at 13:20
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
As Peter Pajchl stated, the contents that your UIWebView gets on its plate are not generally under your control. This means that - unless you only rely on a fixed set of services strictly under your control - you cannot rely on HTTP headers to find out any helpful meta-information.
As he also suggested, you can calculate a checksum of the page contents (that's what a strong Etag would most likely do anyways) and compare it to the newly fetched version. The downside is that the method is inherently strong, and you will get false positives if you are only interested in semantical updates. To render your application useless for a specific site, the owner could just inject a timestamp somewhere into the contents, since every update would yield a different checksum.
You could hence try to normalize the data before calculating a checksum in a way that only takes meaningful data into account. This most likely requires a priori knowledge of the site you are watching in order to be effective.
Another way would be to calculate some kind of similarity metric (with or without normalization) and have a threshold on the "updated" alert. This can be computationally demanding, and what's worse, it may require even more a priori information (at least the metaparameters like the treshold).
Are you trying to watch any arbitrary page on the internet, or is it intended for a page the app has some understanding of the content publishing? If you are trying to figure this out via just the HTTP transaction and the received content, Sami and Peter have laid out a lot of the architectural limitations to this approach.
– benc
Dec 2 at 3:41
Trying to watch any page on the internet.
– Charlie Seligman
Dec 3 at 8:49
add a comment |
up vote
0
down vote
I think Sami Hult made a good point about trying to find meaningful data to calculate a checksum.
I may suggest trying to look for content as Safari reader, it won't work with every possible internet page but may work for blogs and news sites.
For reference have a look at this
https://medium.com/@mandy.michael/building-websites-for-safari-reader-mode-and-other-reading-apps-1562913c86c9
Some news sites will likely update themselves at regular intervals to show new content so you'll be able to get notified just by implementing the delegate method shouldstartloadwithrequest.
I'd avoid http headers for arbitrary pages.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431314%2fhow-to-tell-when-uiwebview-content-changes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
As Peter Pajchl stated, the contents that your UIWebView gets on its plate are not generally under your control. This means that - unless you only rely on a fixed set of services strictly under your control - you cannot rely on HTTP headers to find out any helpful meta-information.
As he also suggested, you can calculate a checksum of the page contents (that's what a strong Etag would most likely do anyways) and compare it to the newly fetched version. The downside is that the method is inherently strong, and you will get false positives if you are only interested in semantical updates. To render your application useless for a specific site, the owner could just inject a timestamp somewhere into the contents, since every update would yield a different checksum.
You could hence try to normalize the data before calculating a checksum in a way that only takes meaningful data into account. This most likely requires a priori knowledge of the site you are watching in order to be effective.
Another way would be to calculate some kind of similarity metric (with or without normalization) and have a threshold on the "updated" alert. This can be computationally demanding, and what's worse, it may require even more a priori information (at least the metaparameters like the treshold).
Are you trying to watch any arbitrary page on the internet, or is it intended for a page the app has some understanding of the content publishing? If you are trying to figure this out via just the HTTP transaction and the received content, Sami and Peter have laid out a lot of the architectural limitations to this approach.
– benc
Dec 2 at 3:41
Trying to watch any page on the internet.
– Charlie Seligman
Dec 3 at 8:49
add a comment |
up vote
2
down vote
accepted
As Peter Pajchl stated, the contents that your UIWebView gets on its plate are not generally under your control. This means that - unless you only rely on a fixed set of services strictly under your control - you cannot rely on HTTP headers to find out any helpful meta-information.
As he also suggested, you can calculate a checksum of the page contents (that's what a strong Etag would most likely do anyways) and compare it to the newly fetched version. The downside is that the method is inherently strong, and you will get false positives if you are only interested in semantical updates. To render your application useless for a specific site, the owner could just inject a timestamp somewhere into the contents, since every update would yield a different checksum.
You could hence try to normalize the data before calculating a checksum in a way that only takes meaningful data into account. This most likely requires a priori knowledge of the site you are watching in order to be effective.
Another way would be to calculate some kind of similarity metric (with or without normalization) and have a threshold on the "updated" alert. This can be computationally demanding, and what's worse, it may require even more a priori information (at least the metaparameters like the treshold).
Are you trying to watch any arbitrary page on the internet, or is it intended for a page the app has some understanding of the content publishing? If you are trying to figure this out via just the HTTP transaction and the received content, Sami and Peter have laid out a lot of the architectural limitations to this approach.
– benc
Dec 2 at 3:41
Trying to watch any page on the internet.
– Charlie Seligman
Dec 3 at 8:49
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
As Peter Pajchl stated, the contents that your UIWebView gets on its plate are not generally under your control. This means that - unless you only rely on a fixed set of services strictly under your control - you cannot rely on HTTP headers to find out any helpful meta-information.
As he also suggested, you can calculate a checksum of the page contents (that's what a strong Etag would most likely do anyways) and compare it to the newly fetched version. The downside is that the method is inherently strong, and you will get false positives if you are only interested in semantical updates. To render your application useless for a specific site, the owner could just inject a timestamp somewhere into the contents, since every update would yield a different checksum.
You could hence try to normalize the data before calculating a checksum in a way that only takes meaningful data into account. This most likely requires a priori knowledge of the site you are watching in order to be effective.
Another way would be to calculate some kind of similarity metric (with or without normalization) and have a threshold on the "updated" alert. This can be computationally demanding, and what's worse, it may require even more a priori information (at least the metaparameters like the treshold).
As Peter Pajchl stated, the contents that your UIWebView gets on its plate are not generally under your control. This means that - unless you only rely on a fixed set of services strictly under your control - you cannot rely on HTTP headers to find out any helpful meta-information.
As he also suggested, you can calculate a checksum of the page contents (that's what a strong Etag would most likely do anyways) and compare it to the newly fetched version. The downside is that the method is inherently strong, and you will get false positives if you are only interested in semantical updates. To render your application useless for a specific site, the owner could just inject a timestamp somewhere into the contents, since every update would yield a different checksum.
You could hence try to normalize the data before calculating a checksum in a way that only takes meaningful data into account. This most likely requires a priori knowledge of the site you are watching in order to be effective.
Another way would be to calculate some kind of similarity metric (with or without normalization) and have a threshold on the "updated" alert. This can be computationally demanding, and what's worse, it may require even more a priori information (at least the metaparameters like the treshold).
answered Dec 1 at 7:54
Sami Hult
1,875413
1,875413
Are you trying to watch any arbitrary page on the internet, or is it intended for a page the app has some understanding of the content publishing? If you are trying to figure this out via just the HTTP transaction and the received content, Sami and Peter have laid out a lot of the architectural limitations to this approach.
– benc
Dec 2 at 3:41
Trying to watch any page on the internet.
– Charlie Seligman
Dec 3 at 8:49
add a comment |
Are you trying to watch any arbitrary page on the internet, or is it intended for a page the app has some understanding of the content publishing? If you are trying to figure this out via just the HTTP transaction and the received content, Sami and Peter have laid out a lot of the architectural limitations to this approach.
– benc
Dec 2 at 3:41
Trying to watch any page on the internet.
– Charlie Seligman
Dec 3 at 8:49
Are you trying to watch any arbitrary page on the internet, or is it intended for a page the app has some understanding of the content publishing? If you are trying to figure this out via just the HTTP transaction and the received content, Sami and Peter have laid out a lot of the architectural limitations to this approach.
– benc
Dec 2 at 3:41
Are you trying to watch any arbitrary page on the internet, or is it intended for a page the app has some understanding of the content publishing? If you are trying to figure this out via just the HTTP transaction and the received content, Sami and Peter have laid out a lot of the architectural limitations to this approach.
– benc
Dec 2 at 3:41
Trying to watch any page on the internet.
– Charlie Seligman
Dec 3 at 8:49
Trying to watch any page on the internet.
– Charlie Seligman
Dec 3 at 8:49
add a comment |
up vote
0
down vote
I think Sami Hult made a good point about trying to find meaningful data to calculate a checksum.
I may suggest trying to look for content as Safari reader, it won't work with every possible internet page but may work for blogs and news sites.
For reference have a look at this
https://medium.com/@mandy.michael/building-websites-for-safari-reader-mode-and-other-reading-apps-1562913c86c9
Some news sites will likely update themselves at regular intervals to show new content so you'll be able to get notified just by implementing the delegate method shouldstartloadwithrequest.
I'd avoid http headers for arbitrary pages.
add a comment |
up vote
0
down vote
I think Sami Hult made a good point about trying to find meaningful data to calculate a checksum.
I may suggest trying to look for content as Safari reader, it won't work with every possible internet page but may work for blogs and news sites.
For reference have a look at this
https://medium.com/@mandy.michael/building-websites-for-safari-reader-mode-and-other-reading-apps-1562913c86c9
Some news sites will likely update themselves at regular intervals to show new content so you'll be able to get notified just by implementing the delegate method shouldstartloadwithrequest.
I'd avoid http headers for arbitrary pages.
add a comment |
up vote
0
down vote
up vote
0
down vote
I think Sami Hult made a good point about trying to find meaningful data to calculate a checksum.
I may suggest trying to look for content as Safari reader, it won't work with every possible internet page but may work for blogs and news sites.
For reference have a look at this
https://medium.com/@mandy.michael/building-websites-for-safari-reader-mode-and-other-reading-apps-1562913c86c9
Some news sites will likely update themselves at regular intervals to show new content so you'll be able to get notified just by implementing the delegate method shouldstartloadwithrequest.
I'd avoid http headers for arbitrary pages.
I think Sami Hult made a good point about trying to find meaningful data to calculate a checksum.
I may suggest trying to look for content as Safari reader, it won't work with every possible internet page but may work for blogs and news sites.
For reference have a look at this
https://medium.com/@mandy.michael/building-websites-for-safari-reader-mode-and-other-reading-apps-1562913c86c9
Some news sites will likely update themselves at regular intervals to show new content so you'll be able to get notified just by implementing the delegate method shouldstartloadwithrequest.
I'd avoid http headers for arbitrary pages.
answered Dec 8 at 17:01
Gualtiero Frigerio
164
164
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53431314%2fhow-to-tell-when-uiwebview-content-changes%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
If the web pages displayed in the view are not under your control then each will have different setup (headers, caching, etc.) making IMO virtually impossible to observe the change in bullet proof way. Can you generate a checksum of the html page (data itself) on each load and compare "current" vs "new"?
– Peter Pajchl
Nov 22 at 13:20