ASP读取淘宝CVS数据包

人气:
41
日期:
2019/9/24
HTML 网页设计 W3C 41

摘要:ASP读取淘宝CVS数据包

这里已经把大部分的代码给出了,稍加改动就可以整合进自己的网站。
导入数据库的部分太简单了,所以就不给代码了。
Function DelHtml(Str1)'格式化html
  Dim regEx
  Set regEx = New RegExp
  regEx.Pattern = "(<[^>]*?>)"
  regEx.Global = True
  regEx.IgnoreCase = True
  DelHtml = replace(regEx.Replace(""&str1,"")," ","")
End Function
 
Function Getfilepo(str,shu)
filepo=split(str,Chr(9))
Getfilepo=filepo(shu)
End Function
 
Function Getfimgcco(str,shu)
if instr(str,"|")<>0 then
filepooo=split(str,"|")
if ubound(filepooo)-1 >= shu then
Getfimgcco=filepooo(shu)
else
Getfimgcco=""
end if
else
Getfimgcco=str
end if
End Function
Function Getfileimg(str,strs)
if instr(str,":")<>0 then
filepoc=split(str,":")
Getfileimg=filepoc(strs)
else
Getfileimg=str
end if
End Function
 
Function regx(patrn, str)
 Dim regEx, Match, Matches
 Set regEx = New RegExp
 regEx.Pattern = patrn
 regEx.IgnoreCase = True
 regEx.Global = True
 Set Matches = regEx.Execute(str)
 For Each Match in Matches
 RetStr = RetStr & Match.Value & " "
 Next
 regx = RetStr
End Function
 
Function Getfileimgss(str,imgpath)
if str<>"" then
if instr(str,".jpg")<>0 then
Getfileimgss=regx("http.*?jpg",str)
else
Getfileimgss="/uploadfile/Thumb/"&imgpath&"/"&Replace_img(Getfileimg(str,0))&".jpg"
end if
end if
End Function
function Replace_content(fString)
if isnull(fString) then
Replace_content=""
exit function
else
fString=trim(fString)
fString=replace(fString,chr(34)&chr(34),chr(34))
fString=replace(fString,"<p>"," ",1,-1,1)    '
fString=replace(fString,"</p>","",1,-1,1)
Replace_content=fString
end if 
end function
function Replace_img(fString)
if isnull(fString) then
Replace_img=""
exit function
else
fString=trim(fString)
fString=replace(fString,"'","")
fString=replace(fString,chr(34),"")
fString=replace(fString,";","")
fString=replace(fString,":0","")
fString=replace(fString,":1","")
fString=replace(fString,":2","")
fString=replace(fString,":3","")
fString=replace(fString,":4","")
fString=replace(fString,":5","")
fString=replace(fString,":6","")
fString=replace(fString,":7","")
fString=replace(fString,":8","")
fString=replace(fString,":9","")
fString=replace(fString,"|","")
fString=replace(fString,"::","")
fString=server.htmlencode(fString)
Replace_img=fString
end if 
end function
 
 
filepath="111111.csv"
 
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath(filepath),1,True,-1)
f.SkipLine
myNum=1
do while f.AtEndOfStream = false
Files=f.ReadLine
 
 
shopname=replace(DelHtml(Getfilepo(Files,0)),chr(34),"")'名字
huiyuanjia=replace(DelHtml(Getfilepo(Files,7)),chr(34),"") '价格
 
'=====================================================
content1=Replace_content(Getfilepo(Files,25))
content2=Replace_content(Getfilepo(Files,24))
if content1="" then
content=content2
else
content=content1
end if
'==========================================说明====
 
 
kucun=replace(DelHtml(Getfilepo(Files,9)),chr(34),"") '库存
 
img=Getfilepo(DelHtml(Files),36)
if instr(img,":0")=0 then
img=Getfilepo(DelHtml(Files),35)
end if
 
shoppic=Getfileimgss(Getfimgcco(img,0),imgpath)  ' 图片
 
response.Write "名字:"&shopname&" - 价格"&huiyuanjia&" - 库存"&kucun&" - 第一张图"&shoppic&"<br>"
 
 
myNum=myNum+1
loop
f.Close
Set f=Nothing
Set fs=Nothing

————————————————

原文链接:https://blog.csdn.net/qq19124152/article/details/7764341



Copyright © 2014 ASP技巧教程源码大全 All Rights Reserved
晋ICP备14006235号-3 页面执行时间:77.637毫秒 返回顶部

?分享按钮