0

essentially, I'm trying to retrieve the contents of a website I created to display time-based one-time passcodes as part of a project I'm doing for fun. the site in question is here. as you can see, all it does is display a totp. however, I'm having trouble actually getting the data from the site.

I've created a small script that is meant to get the totp from the web page, but upon running a fetch request like this (from another server):

const getResponseFromTOTP = () =>
  new Promise((resolve, reject) => {
    try {
      fetch("https://jpegzilla.com/totp/?secret=secrettextgoeshere&length=6")
        .then(res => res.text())
        .then(html => resolve(html));
    } catch (e) {
      reject(e);
    }
  });

from this request, I get the entirety of the document at the url -- but without the content that would be rendered there if viewed by a browser.

the idea is to somehow get javascript to render the content of the webpage as it would be displayed if viewed by a browser, and then extract the totp from the document. the site hosting the totp is completely static; how might this be achieved using only javascript and html?

jpegzilla
  • 80
  • 2
  • 10
  • See https://stackoverflow.com/questions/10642289/return-html-content-as-a-string-given-url-javascript-function – TechFree Jun 10 '19 at 08:54
  • if you control the data website, return the data as a json response on a different url like https://jpegzilla.com/api/totp. – Dov Rine Jun 10 '19 at 09:25
  • 1
    If you don't control the data website, then you'll have to extract the function and run it yourself. – Dov Rine Jun 10 '19 at 09:37
  • @DovRine that makes sense. I don't control the backend, so I'll try extracting the function. thanks! – jpegzilla Jun 10 '19 at 11:47

0 Answers0