问题描述
我正在扫描HTML文件。
我需要从以< SMALL>开头的区域收集某些数据。文本。
让我展示代码,然后解释更多。
----
设置fso = CreateObject(& ; Scripting.FileSystemObject")
设置f = fso.GetFile(TheFilePath)
设置ts = f.OpenAsTextStream(1,-2)
Section =" Header"
Do while not ts.AtEndOfStream
Tmp_Line = ts.ReadLine
选择Case mid(Tmp_Line,48,2)
Case"
Section =" TheMoney"
Case" Pi"
案例"> J"
Section =" TheDate"
结束选择
选择案例部分
CaseTheMoney
TheMoney = TheMoney& FixGrades(Tmp_Line)& CHR(13)
案例ThePick
ThePick = ThePick& FixGrades(Tmp_Line)& CHR(13)
案例TheDate
TheDate = TheDate& FixGrades(Tmp_Line)& CHR(13)
结束选择
TextStreamTest = TextStreamTest& CHR(13)& FixGrades(Tmp_Line)
response.write TheMoney& "< BR>"
response.write ThePick& "< BR>"
response.write TheDate& "< BR>"
循环
ts.Close
---------- -
我的最终结果是能够获取TheMoney,ThePick,TheDate,然后将它们插入一个sql db中。然后扫描更多的html来查找
信息的下一个实例并插入到数据库中。我可以做所有db的东西。数据是
只是没有正确拉动。它会扫描每一行,而不仅仅是以HTML代码< SMALL>开头的
部分。我怎么能这样做
这个?然后,你看到我的最终结果我做错了吗?
我想用我的response.write图像看到文本显示为:
TheMoney
ThePick
TheDate
然后扫描html并找到另一个实例
TheMoney
ThePick
TheDate
等.....
I am scanning an HTML file.
I need to gather certain data from areas that start with <SMALL> text.
Let me show the code, then explain more.
----
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(TheFilePath)
Set ts = f.OpenAsTextStream(1,-2)
Section = "Header"
Do While not ts.AtEndOfStream
Tmp_Line = ts.ReadLine
Select Case mid(Tmp_Line,48,2)
Case " "
Section = "TheMoney"
Case "Pi"
Section = "ThePick"
Case ">J"
Section = "TheDate"
End Select
Select Case Section
Case "TheMoney"
TheMoney = TheMoney & FixGrades(Tmp_Line) & CHR(13)
Case "ThePick"
ThePick = ThePick & FixGrades(Tmp_Line) & CHR(13)
Case "TheDate"
TheDate = TheDate & FixGrades(Tmp_Line) & CHR(13)
End Select
TextStreamTest = TextStreamTest & CHR(13) & FixGrades(Tmp_Line)
response.write TheMoney & "<BR>"
response.write ThePick & "<BR>"
response.write TheDate & "<BR>"
Loop
ts.Close
-----------
My end result is to be able to grab TheMoney,ThePick,TheDate and then insert
them into a sql db. Then to scan more html to find the next instance of the
information and insert into database. I can do all the db stuff. The data is
just not pulling correctly. And it scans EVERY LINE instead of only the
sections that start with the HTML code <SMALL>. How would I get it to do
this? Then, do you see anything else I am doing wrong for my end result?
I''d image seeing the text with my response.write displayed as:
TheMoney
ThePick
TheDate
then scanning the html and finding another instance
TheMoney
ThePick
TheDate
etc....
推荐答案
数据是
data is
没有冒犯雷,但每当我看到这种技术,我总是试图纠正它。我认为以下内容将更加高效(至少对某个文件大小阈值而言),因为在整个编码逻辑中你没有对文件进行处理。
s = ts.ReadAll()
ts.close:set ts = nothing
s = split(s,VBCrLf)
for i = 0 to ubound(s)
sPart = Mid(s(i)& String(49,"),48,2)
...
$
将有一个上限提高效率,因为在50 MB文件上调用readall()不太可能。但我认为在大多数情况下,上述是一种比不是AtEndOfStream更好的技术。
-
(反向回复地址。)
; Ray at<%= sLocation%> [MVP] QUOT; < myfirstname at lane34 dot com>在
消息新闻中写道:#D ************** @ TK2MSFTNGP10.phx.gbl ...
No offense Ray, but whenever I see this technique, I always try to correct
it. I think the following will be much more efficient (to a certain file
size threshold, at least), since you''re not keeping a handle on the file
throughout your coding logic.
s = ts.ReadAll()
ts.close: set ts = nothing
s = split(s, VBCrLf)
for i = 0 to ubound(s)
sPart = Mid(s(i) & String(49, " "), 48, 2)
...
next
There will be an upper bound to the improved efficiency, as calling
readall() on a 50 MB file is not likely to be pretty. But I think in most
cases the above is a better technique than While not AtEndOfStream.
--
http://www.aspfaq.com/
(Reverse address to reply.)
"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:#D**************@TK2MSFTNGP10.phx.gbl...
trim
trim
将
数据
以HTML代码< SMALL>开头的部分。我怎么能得到
这样做?然后,你看到我的结果
结果我做错了什么?
我会用我的response.write图像看到文本显示为:
TheMoney
ThePick
TheDate
然后扫描html并找到另一个实例
TheMoney
ThePick
TheDate
等......
the sections that start with the HTML code <SMALL>. How would I get it todo this? Then, do you see anything else I am doing wrong for my endresult?
I''d image seeing the text with my response.write displayed as:
TheMoney
ThePick
TheDate
then scanning the html and finding another instance
TheMoney
ThePick
TheDate
etc....
这篇关于案例帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!