我来拿个回帖分
路途皆是迷路客,一语还归大道中。
CLEAR DIMENSION aTemplets[4] aTemplets[1] = "19999999999" aTemplets[2] = "99-999-99999999" aTemplets[3] = "999-99999999" aTemplets[4] = "9999999" nFile = FOPEN("2.htm") DO WHILE !FEOF(nFile) cText = FGETS(nFile) FOR nIndex = 1 TO ALEN(aTemplets,1) cBuffer = cText cResult = "" nPos = FindAs(aTemplets[nIndex], cBuffer, @cResult) DO WHILE nPos > 0 ? cResult cBuffer = SUBSTR(cBuffer, nPos + LEN(aTemplets[nIndex])) nPos = FindAs(aTemplets[nIndex], cBuffer, @cResult) ENDDO NEXT ENDDO FCLOSE(nFile) RETURN FUNCTION FindAs(tcTemplet, tcString, tcResult) LOCAL lnIndex, lnCount, llFound LOCAL lnPos, lcCharacter lnPos = 0 tcResult = "" IF LEN(tcTemplet) > LEN(tcString) RETURN lnPos ENDIF FOR lnIndex = 1 TO LEN(tcString) IF ISDIGIT(SUBSTR(tcString, lnIndex, 1)) lnPos = lnIndex llFound = .T. FOR lnCount = 1 TO LEN(tcTemplet) lcCharacter = SUBSTR(tcString, lnIndex + lnCount - 1, 1) IF (SUBSTR(tcTemplet, lnCount, 1) == '9') .AND. ISDIGIT(lcCharacter) tcResult = tcResult + lcCharacter ELSE IF lcCharacter == SUBSTR(tcTemplet, lnCount, 1) tcResult = tcResult + lcCharacter ELSE llFound = .F. lnPos = 0 tcResult = "" EXIT ENDIF ENDIF NEXT IF llFound EXIT ENDIF lnIndex = lnIndex + lnCount - 1 ENDIF NEXT RETURN lnPos ENDFUNC
CLEAR CSTR=[] FOR I=1 TO 30 URL =[http://shuma.]+TRANSFORM(I)+[.html] HTTP = CREATEOBJECT("MICROSOFT.XMLHTTP") HTTP.OPEN("GET", URL,.F.) HTTP.SEND MSG = HTTP.RESPONSETEXT MSG=STRCONV(STRCONV(MSG,11),2) FOR J=1 TO OCCURS([<li class="ot"><span>???],MSG) CSTR=CSTR+STREXTRACT(MSG,[<li class="ot"><span>???],[</span><span>],J)+CHR(13)+CHR(10) ENDFOR ENDFOR =STRTOFILE(CSTR,[TT.TXT]) MODIFY FILE TT.TXT代码不是太完善(提取的网页内容为UTF-8格式,没转换到位),但能达到楼主的要求。