回复 11# lxh623 - var fso = new ActiveXObject('Scripting.FileSystemObject');
- var http = new ActiveXObject('Microsoft.XMLHTTP');
- //var map = {'首页':'word','优质造句':'wordy','小学生造句':'wordx','中学生造句':'wordz','成语造句':'wordcy','关联词造句':'glc','名言佳句':'wordmj','短信句子':'dx'};
- var map = {'网络词语造句':'wordw', '短信句子':'dx'};
- var home = 'http://zaojv.com/';
-
- for (var key in map) {
- var url = home + map[key] + '.html';
- var reg = /style="color: #256EB1;" href="\/([^"]*\.html)" target="_blank">([^<]*?)<\/a>/g;
-
- while(url != '') {
- var txt = getText(url);
- var m = txt.match(/href="(.*\.html)">下一页/);
- url = m ? home + m[1] : '';
- while(arr=reg.exec(txt)) {
- getSentence(home + arr[1], arr[2]);
- }
- }
- }
-
- function getText(url) {
- http.open('GET', url, false);
- http.send();
- with(new ActiveXObject('ADODB.Stream')){
- Mode = 3; Type = 1;
- Open();
- Write(http.responseBody);
- Position = 0;
- Type = 2;
- Charset = 'utf-8';
- var s = ReadText(-1);
- }
- return s;
- }
-
- function getSentence(url, keyWord) {
- var stc = [];
- while(url != '') {
- var s = getText(url);
- var m = s.match(/href="(.*\.html)">下一页/);
- if (key == '短信句子') {
- var r = /erweima\('(.+?)'/g;
- url = m ? home + 'type/' + m[1] : '';
- } else {
- s = s.split(/<div id="all"|<!--all结束-->/)[1];
- var r = /<div>(.+?)<\/div>/g;
- url = m ? home + m[1] : '';
- }
- while(a=r.exec(s)) {
- stc.push(a[1].replace(/<[^>]*>( )?/g, ''));
- }
- }
- writeToFile('A' + keyWord + '\r\n' + stc.join('\r\n'));
- }
-
- function writeToFile(str) {
- var objFile = fso.OpenTextFile(key + '.Log', 8, true);
- objFile.WriteLine(str);
- objFile.Close();
- }
-
- WSH.Echo('Done')
复制代码
|