如何提取网页内的数据
如何编程实现。然后保存在DBF表中。一共有486页数据。
http://www.
starttime=SECONDS()*1000 CLEAR test=CREATEOBJECT("msxml2.xmlhttp") CREATE CURSOR 安徽药品采购 (商品流水号 c(6),通用名 c (40),剂型 c (20),规格 c(60),包装 c(9),生产企业 c(40),中标价 c(10)) FOR i = 1 TO 476 weblites=[http://www.]+TRANSFORM(i) test.OPEN("get", weblites,.F.) test.SEND shuchu="" shuchu= STRCONV(test.responsetext,2) shuchu=STRTRAN(shuchu,CHR(10),"") shuchu=STRTRAN(shuchu,CHR(13),"") shuchu=STRTRAN(shuchu,CHR(8),"") shuchu=STRTRAN(shuchu,CHR(9),"") shuchu=STRTRAN(shuchu,CHR(11),"") shuchu=STRTRAN(shuchu,CHR(12),"") shuchu=STREXTRACT(shuchu,[</tr><tr>],[</td></tr></table>]) DIMENSION ziduan(7) DO WHILE not EMPTY(shuchu) FOR ii=1 TO 7 ziduan(ii)=STREXTRACT(shuchu,[<td>],[</td>]) shuchu=STREXTRACT(shuchu,[</td>],[]) ENDFOR INSERT INTO 安徽药品采购 FROM ARRAY ziduan shuchu=STREXTRACT(shuchu,[</tr><tr>],[]) ENDDO ENDFOR endtime=SECONDS()*1000 TIMES=endtime-starttime MESSAGEBOX("你所花费的时间为"+ALLTRIM(STR(TIMES,20))+"毫秒",64,"测试") BROWSE
//<![CDATA[ var theForm = document.forms['aspnetForm']; if (!theForm) { theForm = document.aspnetForm; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } //]]>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" /> <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" /> <input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" /> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"
<a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$pager1','17')">
CLEAR CREATE CURSOR YPINFO (流水号 C(5),通用名 C(40),剂型 C(40),规格 C(40),包装 C(40),企业名称 C(60),中标价 N(8,2)) T1=SECONDS() FOR P=1 TO 476 LCURL=[http://www.]+TRANSFORM(P) &&翻页数据提取关键所在,刚从月版处偷来的。 OHTML = CREATEOBJECT("MICROSOFT.XMLHTTP") OHTML.OPEN([GET],LCURL,.F.) OHTML.SEND LCSTR = STRCONV(OHTML.RESPONSETEXT,2) LCSTR=[</tr><tr>]+STREXTRACT(LCSTR,[</tr><tr>],[</table>]) FOR I=1 TO OCCURS([</tr><tr>],LCSTR) A=STREXTRACT(LCSTR,[</tr><tr>],[</td>]+CHR(13)+CHR(10),I)+[</td>] LOCAL B(7) FOR I1=1 TO OCCURS([<td>],A) B(I1)=STREXTRACT(A,[<td>],[</td>],I1) ENDFOR INSERT INTO YPINFO VALUES (PADL(B(1),5,[0]),B(2),B(3),B(4),B(5),B(6),VAL(B(7))) ENDFOR ENDFOR MESSAGEBOX([提取数据共用了]+TRANSFORM((SECONDS()-T1)*1000)+[毫秒]) BROWSE