[英]Reading a html page and inserting it to database using classic asp
我试图逐行读取一个HTML页面(文件)及其标签,然后使用经典ASP将其插入数据库。 我的问题是我无法阅读html标签,例如
<p>Test</p>
要么
<td width="20%">Hello</td>
相反,我读了“测试”或“你好”。 我还知道我必须将“转换为”,何时应该替换它呢?这是我读取的代码:
Dim url,strArr,xmlhttp,lineno
url = "http://localhost/0/questions/q.html"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.send ""
strArr = split(xmlhttp.responseText,vbcrlf)
set xmlhttp = nothing
for lineno=0 to ubound(strArr)
' Here I do replacement, parsing and then insertion to database
next
尝试使用responseHTML而不是responseText:
strArr = split(xmlhttp.responseHTML,vbcrlf)
尝试这个:
Dim url,strArr,xmlhttp,lineno
url = "http://localhost/0/questions/q.html"
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", url, false
xmlhttp.send ""
strArr = split(xmlhttp.responseText,vbcrlf)
set xmlhttp = nothing
for lineno=0 to ubound(strArr)
response.write(Replace(strArr(lineno),"<","<'"))
next
如果仅在页面中放置response.write(strArr(lineno)),则只会看到html标记内的内容,而不是标记本身。 但是,如果您确实将strArr(lineno)插入数据库中,则只要替换所有撇号就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.