How to tell when UIWebView content changes?











up vote
0
down vote

favorite
1












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?










share|improve this question




















  • 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















up vote
0
down vote

favorite
1












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?










share|improve this question




















  • 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













up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





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?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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














  • 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












2 Answers
2






active

oldest

votes

















up vote
2
down vote



accepted
+250










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).






share|improve this answer





















  • 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


















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.






share|improve this answer





















    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
    });


    }
    });














    draft saved

    draft discarded


















    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
    +250










    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).






    share|improve this answer





















    • 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















    up vote
    2
    down vote



    accepted
    +250










    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).






    share|improve this answer





















    • 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













    up vote
    2
    down vote



    accepted
    +250







    up vote
    2
    down vote



    accepted
    +250




    +250




    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).






    share|improve this answer












    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).







    share|improve this answer












    share|improve this answer



    share|improve this answer










    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


















    • 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












    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.






    share|improve this answer

























      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.






      share|improve this answer























        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.






        share|improve this answer












        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Dec 8 at 17:01









        Gualtiero Frigerio

        164




        164






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)