-
Read Javascript Object
I'm able to get an external sites HTML code. Inside that code they have a javascript code which has a JS object called myListItems.
I know how to get the HTML via file_get_contents but how canI scrape the JS code so I can use it?
-
Essentially you can't. Javascript is client side so you cannot know what is happening when executed by the user/browser. You can pull the script itself depending on if it is embedded in the HTML or pulled from a file. You would have to analyze the <javascript> tag(s) to determine which. After that you would need to know what the user/browser actions are to execute it. Finally you would have to emulate its execution on the server using the same conditions as the user/browser. All of that is virtually impossible.
There are 10 kinds of people in the world. Those that understand binary and those that don't.
June 30th, 2018, 08:33 AM
-
<p id="demo"></p>
<script>
// Create an object:
var person = {firstName:"John", lastName:"Doe", age:50, eyeColor:"blue"};
// Display some data from the object:
document.getElementById("demo").innerHTML =
person.firstName + " is " + person.age + " years old.";
</script>
June 30th, 2018, 09:09 AM
-
That does not answer the OP. As I said it is not possible.
There are 10 kinds of people in the world. Those that understand binary and those that don't.
June 30th, 2018, 09:10 AM
-
That does not answer the OP. As I said it is not possible.
P.S. Please use code tags when posting non-PHP code.
There are 10 kinds of people in the world. Those that understand binary and those that don't.