本帖最后由 WHY 于 2019-7-26 11:28 编辑
- var txt = getText('https://www.manhuadb.com');
-
- var arr = [], m = [], map = [];
- var reg = /src="((?:https?:\/)?\/[^"]+\.jpe?g)"/ig; //匹配 src="https://...jpg" 或者 src="/...jpg"
- while( m = reg.exec(txt) ){
- var s = m[1].toLowerCase().replace(/^\//, 'https://www.manhuadb.com/');
- if( !map[s] ){ //去重复
- arr.push(s); map[s] = 1;
- }
- }
-
- writeToFile(arr);
-
- //提取网页
- function getText(url) {
- var http = new ActiveXObject('Microsoft.XMLHTTP');
- http.open('GET', url, false);
- http.send();
- with( new ActiveXObject('ADODB.Stream') ){
- Type = 1;
- Mode = 3;
- Open();
- Write(http.responseBody);
- Position = 0;
- Type = 2;
- Charset = 'UTF-8';
- var str = ReadText(-1);
- }
- return str;
- }
-
- //写入文本
- function writeToFile(arr) {
- var fso = new ActiveXObject('Scripting.FileSystemObject');
- fso.OpenTextFile('result.Log', 2, true).WriteLine(arr.join('\r\n'));
- }
-
- WSH.Echo('Done');
复制代码
|