当前位置:编程学习 > asp >>

ASP如何在一串HTML代码中获取所有图片的名字

<P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"></SPAN> </P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104404494.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">基地种植园</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104416733.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">家长社区人员参加学校开放日听课评课活动</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104427854.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">家长学校全方位为家长服务</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104436382.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">家长在科技创新基地指导学生栽土豆</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104446543.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">教师、家长、社区人员共同开展实践活动</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104501354.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">师生、家长参演的节目获四平市校园文化节一等奖</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104536710.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">市、县领导光临基地指导工作</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104544621.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA"><SPAN style="FONT-SIZE: 14px; mso-spacerun: yes"><FONT style="FONT-SIZE: 14px"> </FONT></SPAN>市关工委领导指导课题研究</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104554453.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">学生为老人奉献一片爱心</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104606508.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">学生在爱国主义教育基地祭</SPAN><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: 宋体; mso-bidi-font-family: 宋体; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">扫士墓</SPAN></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104615151.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">学生在基地采访老红军</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104626321.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">学校家庭合谐教育竞赛课表彰会</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104635416.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">优秀家长在家庭教育经验介绍</SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px"><IMG src=" http://www.jzjynet.org/admin/eWebEditor/uploadfile/20100505104643653.jpg" border=0></SPAN></P><P style="TEXT-ALIGN: center"><SPAN style="FONT-SIZE: 14px; FONT-FAMILY: 楷体_GB2312; mso-font-kerning: 1.0pt; mso-hansi-font-family: ‘Times New Roman‘; mso-bidi-font-family: ‘Times New Roman‘; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA">在基地为孤独老人服务 </SPAN></P>
追问:给个代码。。不怎么清楚

答案:

function img( S)
Dim iStart, iEnd, iPos, S, T
iPos = 1
Do
    iStart = InStr(iPos, S, "IMG src=""", vbTextCompare)
    If iStart = 0 Or iStart = -1 Then Exit Do
    iStart = iStart + Len("IMG src=""")
    iEnd = InStr(iStart + 1, S, """", vbTextCompare)
    T = T & vbCrLf & Mid(S, iStart, iEnd - iStart)
    iPos = iEnd
Loop
img = T
End Function

用迅雷下图片 
用正则呗。。。

function img( S)
Dim iStart, iEnd, iPos, S, T
iPos = 1
Do
    iStart = InStr(iPos, S, "IMG src=""", vbTextCompare)
    If iStart = 0 Or iStart = -1 Then Exit Do
    iStart = iStart + Len("IMG src=""")
    iEnd = InStr(iStart + 1, S, """", vbTextCompare)
    T = T & vbCrLf & Mid(S, iStart, iEnd - iStart)
    iPos = iEnd
Loop
img = T
End Sub

给你写了个查图片地址的函数,调用 img("网页代码") 它就返回所有的图片地址,多个地址是用Vbcrlf回车+换行分开的.

用Vb6调试成功了

上一个:图片转换成二进制代码存入数据库中(asp+access)
下一个:用asp.net写确定今天是星期几地代码怎么写?

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,