<script type="text/javascript">var xmlhttp; function loadXMLDoc(url) { xmlhttp = null; if (window.XMLHttpRequest) { // code for IE7, Firefox, Opera, etc. xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp != null) { xmlhttp.onreadystatechange = state_Change; xmlhttp.open("GET", url, true); xmlhttp.send(null); } else { alert("Your browser does not support XMLHTTP."); } } function state_Change() { if (xmlhttp.readyState == 4) { // 4 = "loaded" if (xmlhttp.status == 200) { // 200 = "OK" //document.getElementById('A1').innerHTML=xmlhttp.status; //document.getElementById('A2').innerHTML=xmlhttp.statusText; //document.getElementById('A3').innerHTML=xmlhttp.responseText; console.log(typeof xmlhttp.responseText); get_cnblogs_post_body(xmlhttp.responseText); } else { alert("Problem retrieving XML data:" + xmlhttp.statusText); } } } function get_cnblogs_post_body(str){ var start = str.indexOf("cnblogs_post_body") + 41; var stop = str.indexOf("MySignature") -15; var getstr = str.substring(start,stop);// 用于提取字符串中介于两个指定下标之间的字符。 console.log(getstr); } loadXMLDoc('https://www.cnblogs.com/liudongpei/p/6021170.html');</script>
http://www.it610.com/article/1273912.htm