Aides for determining recurring patterns in urls/strings









up vote
-1
down vote

favorite












I am doing data science for sociology research, and am trying to scrape a website by emulating their XHR requests using Python (it is the sort of website that loads more results as you scroll). The next url in the sequence is embedded in the current XHR object code. You just capture this url with regular expressions, decode it, and slap your access token on the end to get the data you want.



After a certain number of iterations, the XHR request fails to return the next url in the sequence, creating a dead end. The urls themselves, however, appear to follow a numerical sequence, which I haven't quite figured out yet. If I could figure out the pattern, I could go back further.



What I am wondering is, are there any good tools out there for comparing differences in url like strings, particularly in Python? The urls are about 1000 characters long, and changes are very hard to eyeball. I need the right tools.



Here is an example similar to what the urls looks like (I can't provide the actual url, because it has my username, access tokens, and other private information), except much shorter and with many fewer changeable sequences:



https://website.com/results/unit=9382729282&unixtime=1541174174&more_variables=x
https://website.com/results/unit=9382729790&unixtime=1541181234&more_variables=x


Note: Someone did suggest to me that I use Selenium to simply scroll infinitely. Aside from the fact infinitely scrolling websites have infinitely growing source code that eventually choke Selenium, the browser JavaScript is requesting the same XHR objects as my Python script. They both stop working at the same place, consequently.










share|improve this question

























    up vote
    -1
    down vote

    favorite












    I am doing data science for sociology research, and am trying to scrape a website by emulating their XHR requests using Python (it is the sort of website that loads more results as you scroll). The next url in the sequence is embedded in the current XHR object code. You just capture this url with regular expressions, decode it, and slap your access token on the end to get the data you want.



    After a certain number of iterations, the XHR request fails to return the next url in the sequence, creating a dead end. The urls themselves, however, appear to follow a numerical sequence, which I haven't quite figured out yet. If I could figure out the pattern, I could go back further.



    What I am wondering is, are there any good tools out there for comparing differences in url like strings, particularly in Python? The urls are about 1000 characters long, and changes are very hard to eyeball. I need the right tools.



    Here is an example similar to what the urls looks like (I can't provide the actual url, because it has my username, access tokens, and other private information), except much shorter and with many fewer changeable sequences:



    https://website.com/results/unit=9382729282&unixtime=1541174174&more_variables=x
    https://website.com/results/unit=9382729790&unixtime=1541181234&more_variables=x


    Note: Someone did suggest to me that I use Selenium to simply scroll infinitely. Aside from the fact infinitely scrolling websites have infinitely growing source code that eventually choke Selenium, the browser JavaScript is requesting the same XHR objects as my Python script. They both stop working at the same place, consequently.










    share|improve this question























      up vote
      -1
      down vote

      favorite









      up vote
      -1
      down vote

      favorite











      I am doing data science for sociology research, and am trying to scrape a website by emulating their XHR requests using Python (it is the sort of website that loads more results as you scroll). The next url in the sequence is embedded in the current XHR object code. You just capture this url with regular expressions, decode it, and slap your access token on the end to get the data you want.



      After a certain number of iterations, the XHR request fails to return the next url in the sequence, creating a dead end. The urls themselves, however, appear to follow a numerical sequence, which I haven't quite figured out yet. If I could figure out the pattern, I could go back further.



      What I am wondering is, are there any good tools out there for comparing differences in url like strings, particularly in Python? The urls are about 1000 characters long, and changes are very hard to eyeball. I need the right tools.



      Here is an example similar to what the urls looks like (I can't provide the actual url, because it has my username, access tokens, and other private information), except much shorter and with many fewer changeable sequences:



      https://website.com/results/unit=9382729282&unixtime=1541174174&more_variables=x
      https://website.com/results/unit=9382729790&unixtime=1541181234&more_variables=x


      Note: Someone did suggest to me that I use Selenium to simply scroll infinitely. Aside from the fact infinitely scrolling websites have infinitely growing source code that eventually choke Selenium, the browser JavaScript is requesting the same XHR objects as my Python script. They both stop working at the same place, consequently.










      share|improve this question













      I am doing data science for sociology research, and am trying to scrape a website by emulating their XHR requests using Python (it is the sort of website that loads more results as you scroll). The next url in the sequence is embedded in the current XHR object code. You just capture this url with regular expressions, decode it, and slap your access token on the end to get the data you want.



      After a certain number of iterations, the XHR request fails to return the next url in the sequence, creating a dead end. The urls themselves, however, appear to follow a numerical sequence, which I haven't quite figured out yet. If I could figure out the pattern, I could go back further.



      What I am wondering is, are there any good tools out there for comparing differences in url like strings, particularly in Python? The urls are about 1000 characters long, and changes are very hard to eyeball. I need the right tools.



      Here is an example similar to what the urls looks like (I can't provide the actual url, because it has my username, access tokens, and other private information), except much shorter and with many fewer changeable sequences:



      https://website.com/results/unit=9382729282&unixtime=1541174174&more_variables=x
      https://website.com/results/unit=9382729790&unixtime=1541181234&more_variables=x


      Note: Someone did suggest to me that I use Selenium to simply scroll infinitely. Aside from the fact infinitely scrolling websites have infinitely growing source code that eventually choke Selenium, the browser JavaScript is requesting the same XHR objects as my Python script. They both stop working at the same place, consequently.







      python string web-scraping pattern-matching data-science






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 22:14









      Alex Heebs

      47117




      47117



























          active

          oldest

          votes











          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%2f53243953%2faides-for-determining-recurring-patterns-in-urls-strings%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53243953%2faides-for-determining-recurring-patterns-in-urls-strings%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







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3

          Museum of Modern and Contemporary Art of Trento and Rovereto