2016-04-24 1 views
1

Ich habe einen jsbin hier https://jsbin.com/wanegavisa/edit?html,js,console und ich versuche NodeJS zu verwenden, um die Ausgabe html https://output.jsbin.com/wanegavisa und analysiert, um den Inhalt innerhalb der javascript Registerkarte im jsbin Editor zum Download . Ich würde einen Dom-Parser wie Cheerio verwenden und das erste <script>-Tag innerhalb der body bekommen. Ich habe gerade gesehen, dass man Skript-Tags direkt zum Körper hinzufügen kann.Weg zum jsbin Ausgabe HTML-Dokument für den Inhalt in ‚javascript‘ zu analysieren Feld

Wie kann ich analysieren ein Dokument wie diese eine Zeichenfolge bekommen

console.log('hi') 

enthält ich das Skript wählen konnte aus dem Skript mit src Geschwister, die auf diese URL https://static.jsbin.com/js/render/edit.js gleich ist. Aber wenn sich diese URL ändert, habe ich kein Glück.

<!DOCTYPE html> 
<html> 
<head> 
<script src="https://code.jquery.com/jquery-1.9.1.js"></script> 
    <meta charset="utf-8"> 
<!-- 
Created using JS Bin 
http://jsbin.com 

Copyright (c) 2016 by anonymous (http://jsbin.com/wanegavisa/2/edit) 

Released under the MIT license: http://jsbin.mit-license.org 
--> 
<meta name="robots" content="noindex"> 
    <meta name="viewport" content="width=device-width"> 
    <title>JS Bin</title> 
</head> 
<body> 

    <script>console.log('meow')</script> 

<script> 
console.log('hi') 
</script> 
<script src="https://static.jsbin.com/js/render/edit.js?3.35.12"></script> 
<script>jsbinShowEdit && jsbinShowEdit({"static":"https://static.jsbin.com","root":"https://jsbin.com"});</script> 
<script src="https://static.jsbin.com/js/vendor/eventsource.js?3.35.12"></script> 
<script src="https://static.jsbin.com/js/spike.js?3.35.12"></script> 
<script> 
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ 
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), 
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) 
})(window,document,'script','//www.google-analytics.com/analytics.js','ga'); 
ga('create', 'UA-1656750-34', 'jsbin.com'); 
ga('require', 'linkid', 'linkid.js'); 
ga('require', 'displayfeatures'); 
ga('send', 'pageview'); 

</script> 

</body> 
</html> 
+1

Verwenden Sie die api statt https://jsbin.com/api/wanegavisa –

Antwort

0

jsbin hat eine api! :)

https://jsbin.com/api/wanegavisa

{ 
    "javascript": "console.log('hi')", 
    "html": "<!DOCTYPE html>\n<html>\n<head>\n<script src=\"https://code.jquery.com/jquery-1.9.1.js\"></script>\n <meta charset=\"utf-8\">\n <meta name=\"viewport\" content=\"width=device-width\">\n <title>JS Bin</title>\n</head>\n<body>\n\n <script>console.log('meow')</script>\n \n</body>\n</html>", 
    "css": "", 
    "settings": { 
    "processors": { 
     "html": "html", 
     "css": "css", 
     "javascript": "javascript" 
    }, 
    "title": "JS Bin" 
    }, 
    "last_updated": "2012-07-23T00:00:00.000Z", 
    "url": "wanegavisa", 
    "snapshot": 2 
} 
Verwandte Themen