Ask coding questions

← Back to all posts
Get innerHTML of page
h
Coder100 (17021)

I have a website that is not on the root domain (meaning if my parser page was on example.com the page to be parsed is on evil-subdomain.example.com):

<p>wooo</p>
<script>
import 'jquery';//pretend this works
$('p').append('Yeet')
</script>

Now I want to use axios to parse the <p> tag.
Now, Axios obviously will say
wooo
but I want it to say woooYeet as the javascript will append that (pretend you can import jquery).
How would I do this so Axios would evaluate the javascript code?

And more importantly...

What if you had a backend that posted the code automatically, so for security reasons, you would have to dynamically get the innerHTML?

For example,

<tag>woooo</tag>
<script src = "supersecurewebsite.website"></script>

and
supersecurewebsite.website
had content of

import 'jquery'; // this works because I say so
$('tag').html("woo")

And for some reason you couldn't parse supersecurewebsite.website and you would have to actively wait 5 seconds for supersecurewebsite.website to do its magic and replace the html of <tag>. So how do you do that?

Thanks in advance!

Comments
hotnewtop
Zavexeon (1188)

Hey, I don't have an answer, but the way you asked this question was excellent!

MatthewDoan1 (336)

Have you tried putting the Axios code after the Jquery code? (I think your code runs in order.)

MatthewDoan1 (336)

@Coder100

<p>wooooooooooo</p>
<script></script> <!--Jquery stuff -->
<script></script> <!--Axios stuff-->

Since HTML5 goes down the document, like Python, I believe this will work, since the Axios code runs after the Jquery code.

Coder100 (17021)

I don't think it will work like this, you would have to async it because javascript actually goes by first come first serve if something takes too long to load and is not specifically specified to be important
so either like

<p>wooooooooooo</p>
<script></script> <!--Jquery stuff -->
<script>async args</script> <!--Axios stuff-->
<p>wooooooooooo</p>
<script></script> <!--Jquery stuff -->
<script>setTimeout(function(){args},5000)</script> <!--Axios stuff-->

@MatthewDoan1

Coder100 (17021)

Oh, ok. See, it is synchronous until it isn't @MatthewDoan1