-1

I'm trying to extract some basic information from a website, but I'm having trouble figuring out how to set the document "source" as the website I'm referencing. For example, if I have something like:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script>
    var user = document.getElementById("the-user").innerHTML
</script>

How can I make it so that the script knows which document to take the ID from (in this case a website that I own)?

Bob John
  • 447
  • 2
  • 4
  • 13

1 Answers1

0

You'll need to retrieve the content from the remote URL and then parse this content as HTML. For this part, I'll refer to this answer: https://stackoverflow.com/a/1069953/1226267

When you have retrieved and parsed the content, you'll be able to use it like this:

var user = xmlDoc.getElementById("the-user").innerHTML

(where xmlDoc is the variable that you stored the parsed content in, this variable name is also used in the referred answer).

Community
  • 1
  • 1
T.S.
  • 1,242
  • 13
  • 22