Originariamente inviato da optime
va' chi si rivede, quello della birretta sicuro sicuro!!!!
Contaci!!!!
Ecco il codice completo dello script... il campo in questione quote è LONGTEXT...
codice:
<%
Response.Expires = -1
Randomize()
intUP = 199
intLow = 1
URLToRSS = "http://www.elpais.com/rss/feed.html?feedId=17042"
MaxNumberOfItems = 20
Keyword1 = ""
Keyword2 = ""
Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
xmlHttp.Open "GET", URLToRSS, false
xmlHttp.Send()
RSSXML = xmlHttp.ResponseText
Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDOM.async = False
xmlDOM.validateOnParse = False
xmlDom.resolveExternals = False
If not xmlDOM.LoadXml(RSSXML) Then
ErrorMessage = "Can not load XML:" & vbCRLF & xmlDOM.parseError.reason & vbCRLF & ErrorMessage
End If
Set xmlHttp = Nothing
Set RSSItems = xmlDOM.getElementsByTagName("item")
RSSItemsCount = RSSItems.Length-1
if RSSItemsCount = -1 Then
Set RSSItems = xmlDOM.getElementsByTagName("entry")
RSSItemsCount = RSSItems.Length-1
End If
Set xmlDOM = Nothing
j = -1
For i = 0 To RSSItemsCount
Set RSSItem = RSSItems.Item(i)
RSSdescription=""
RSSCommentsLink=""
for each child in RSSItem.childNodes
Select case lcase(child.nodeName)
case "title"
RSStitle = child.text
case "link"
If child.Attributes.length>0 Then
RSSLink = child.GetAttribute("href")
if (RSSLink <> "") Then
if child.GetAttribute("rel") <> "alternate" Then
RSSLink = ""
End If
End If
End If
If RSSLink = "" Then
RSSlink = child.text
End If
case "description"
RSSdescription = child.text
case "content" ' atom format
RSSdescription = child.text
case "published"' atom format
RSSDate = child.text
case "pubdate"
RSSDate = child.text
case "comments"
RSSCommentsLink = child.text
case "category"
Set CategoryItems = RSSItem.getElementsByTagName("category")
RSSCategory = ""
for each categoryitem in CategoryItems
if RSSCategory <> "" Then
RSSCategory = RSSCategory & ", "
End If
RSSCategory = RSSCategory & categoryitem.text
Next
End Select
next
If (InStr(RSSTitle,Keyword1)>0) or (InStr(RSSTitle,Keyword2)>0) or (InStr(RSSDescription,Keyword1)>0) or (InStr(RSSDescription,Keyword2)>0) then
j = J+1
if J<MaxNumberOfItems then
ItemContent = Replace(ItemTemplate,"{LINK}",RSSlink)
ItemContent = Replace(ItemContent,"{TITLE}",RSSTitle)
ItemContent = Replace(ItemContent,"{DATE}",RSSDate)
ItemContent = Replace(ItemContent,"{COMMENTSLINK}",RSSCommentsLink)
ItemContent = Replace(ItemContent,"{CATEGORY}",RSSCategory)
Response.Write Replace(ItemContent,"{DESCRIPTION}",RSSDescription)
response.write "DESC = " & RSSDescription & "
" &_
"LINK = " & RSSlink & "
" &_
"TITO = " & RSSTITLE & "
" &_
"DATA = " & RSSDATE & "
" &_
"COMM = " & RSSCOMMENTSLINK & "
" &_
"CATE = " & RSSCATEGORY & "
"
query_select = "SELECT * FROM "
query_select = query_select & " TBL_QUOTE "
query_select = query_select & " WHERE "
query_select = query_select & " author = 'elpais.com' "
query_select = query_select & " AND "
query_select = query_select & " titolo = '" & pulisci(RSSTitle) & "' "
response.write query_select & "
"
response.flush()
set estilosRS = Server.CreateObject("ADODB.Recordset")
estilosRs.Open query_select, objConn
if not estilosRs.eof And not estilosRs.bof then
else
intRange = intUp - intLow
intRandom = CInt ((intRange * Rnd()) + intLow)
intRange2 = intUp + intLow
intRandom2 = CInt ((intRange * Rnd()) - intLow)
strSQL = "INSERT INTO TBL_QUOTE"
strSQL = strSQL & " ("
strSQL = strSQL & " quote, "
strSQL = strSQL & " author, "
strSQL = strSQL & " titolo, "
strSQL = strSQL & " rating, "
strSQL = strSQL & " tot_rating, "
strSQL = strSQL & " URL, "
strSQL = strSQL & " datareg "
strSQL = strSQL & " )"
strSQL = strSQL & " VALUES"
strSQL = strSQL & " ("
if(InStr(RSSDescription, "\xC2\x93m\xC3\xA1s") > 0) then
strSQL = strSQL & " '', "
else
strSQL = strSQL & " '" & pulisci(RSSDescription) & "', "
end if
strSQL = strSQL & " 'elpais.com', "
strSQL = strSQL & " '" & pulisci(RSSTitle) & "', "
strSQL = strSQL & " " & (numero) + intRandom & ", "
strSQL = strSQL & " " & (numero) + intRandom2 & ", "
strSQL = strSQL & " '" & pulisci(RSSlink) & "', "
strSQL = strSQL & " '" & convertDate(Date()) & "' "
strSQL = strSQL & " )"
response.write strsql & "
"
response.flush()
'''objconn.execute strSQL
end if
estilosRS.Close
set estilosRS = nothing
ItemContent = ""
RSSLink = ""
End if
End If
Next
if RSSItemsCount > 0 then
Response.Write MainTemplateFooter
else
Response.Write ErrorMessage
End If
%>