怎么用asp写程序将HTM文件中的与<title>中的值读出?

zhouxinjie 2004-01-09 10:15:26
怎么用asp写程序将HTM文件中的<title>与<title>中的值读出?

例如:
<HEAD><TITLE>程序</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>

就是想将上面的“程序”两个字读出,并且改变一下,怎么办?
...全文
49 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
mygoodbuy 2004-01-10
  • 打赏
  • 举报
回复
trysun(大石头)说得很清楚了,我就不废话了。因为读取出的源代码中找 title是很容易的,在开始是唯一性的嘛!
zhouxinjie 2004-01-10
  • 打赏
  • 举报
回复
老大们的,快告诉我哈,谢谢啦!
xeimm 2004-01-09
  • 打赏
  • 举报
回复
帮你顶~~~
trysun 2004-01-09
  • 打赏
  • 举报
回复
哎呀。。 上面的看不懂啊。。  我该天天向上了!!!

一种思路。 先读取文件内容。 把所有的换行去掉。 然后计算<title>和</title>分别在字串中的位置a,b,。 然后用mid截取

比如:

dim mystr,a,b
mystr=replace(filetext,chr(10),"") '这里的filetext为你从文件里读出来的内容。
mystr="<HEAD><TITLE>程序</TITLE><META http-equiv=Content-Type "
a=instr(4,mystr,"<title>",1)
b=instr(4,mystr,"</title>",1)
a=a+7
b=b-a
mystr=mid(mystr,a,b)

mystr就是你想要的了。。
zhouxinjie 2004-01-09
  • 打赏
  • 举报
回复
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0077)http://jiaowu.swjtu.edu.cn/jwy/bjxsmd_n.asp?bjjdm=1302200103&name=电科2001-03 -->
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY><FONT face=楷体_GB2312><BIG>电科2001-03 班 最近学期学生成绩单</BIG></FONT>
<P></P>

我的那个页面就是这个格式的,那个title中是空的,怎么写程序将其补上去啊?

我的那个文件名是dianke01.htm
那参数该怎么设置,能详细一点吗?谢谢!
ib915 2004-01-09
  • 打赏
  • 举报
回复
<%
set rs=
sql=""
rs.open sql,conn,1,1
…………
…………
title=rs("title")
%>
<title><%=title%></title>
yangzixp 2004-01-09
  • 打赏
  • 举报
回复
nowContent = getHTTPPage(nowurl)

if err.number=0 then
'response.write nowContent
start=newstring(nowContent,"<title>")
over=newstring(nowContent,"</title>")
strContent=mid(nowContent,start+7,over-start-7)
tradetitle=stripsql(trim(strContent))
response.write tradetitle
end if


function getHTTPPage(url)
on error resume next
dim http
set http=Server.createobject("Msxml2.ServerXMLHTTP.3.0")
Http.open "GET",url,false
Http.send "<XML>Sent XML</XML>"
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytes2BSTR(Http.responseBody)
set http=nothing
if err.number<>0 then err.Clear
end function


'将数据转换
Function bytes2BSTR(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function

Function NewString(wstr,strng)
NewString=Instr(wstr,strng)
End Function

28,407

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧