本帖最后由 zhan170 于 2015-9-10 16:20 编辑
[Visual Basic] 纯文本查看 复制代码
<!DOCTYPE html>
<html>
<head>
<meta charset="gb2312">
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="viewport" content="width=device-width" />
<title></title>
</head>
<body>
<%
Sub WriteToTextFile (FileUrl,byval Str,CharSet)
set stm=server.CreateObject("adodb.stream")
stm.Type=2 '以本模式读取
stm.mode=3
stm.charset=CharSet
stm.open
stm.Write str
stm.SaveToFile server.MapPath(FileUrl),2
stm.flush
stm.Close
set stm=nothing
end Sub
function AddLog(FileUrl,str)
filename=Server.MapPath(FileUrl)
Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(filename,8,true)
f.WriteLine(str)
'写入文件中
f.close
set f=nothing
set fs=nothing
end function
%>
<h2>pc端链接批对移动端链接对应生成sogou站长开放设配中url匹配规则xml</h2>
<table>
<form action="360.asp" method=post>
<tr><td><strong>pc端</strong></td><td><strong>移动端</strong></td></tr>
<tr>
<td><textarea name="wd" style="width:400px;height:400px;"></textarea></td>
<td>
<textarea name="sj" style="width:400px;height:400px;"></textarea>
</td>
</tr>
<tr><td colspan=2><input type=submit value="生成"></td></tr>
</form>
</table>
<%
ci=trim(Request.form("wd"))
sj=trim(Request.form("sj"))
if ci<>"" and sj<>"" then
dedearr=split(ci,Chr(13)&chr(10)) '分割成数组
shouji=split(sj,Chr(13)&chr(10))
call AddLog("a.xml","<?xml version=""1.0"" encoding=""UTF-8"" ?>")
call AddLog("a.xml","<urlset>")
for dede=0 to ubound(dedearr)-1 '数组长度减一,因为最后有两个chr(13)换行。
dedeurl=dedearr(dede)
hm=shouji(dede)
call AddLog("a.xml","<url>"&Chr(13)&"<loc>"&dedearr(dede)&"</loc>"&Chr(13)&"<data>"&Chr(13)&"<display>"&Chr(13)&"<url_pattern>"&hm&"</url_pattern>"&Chr(13)&"<version>7</version>"&Chr(13)&"</display>"&Chr(13)&"</data>"&Chr(13)&"</url>")
next
call AddLog("a.xml","</urlset>")
end if
%>
</body></html>
弄个小旋风复制源码成asp文件运行就ok了。
生成后文件内容:
[XML] 纯文本查看 复制代码
<?xml version="1.0" encoding="UTF-8" ?>
<urlset>
<url>
<loc>pc端链接</loc>
<data>
<display>
<url_pattern>移动端链接</url_pattern>
<version>7</version>
</display>
</data>
</url>
</urlset>
|