how to grab content from another site

  • Thread starter Christopher Brandsdal
  • Start date
C

Christopher Brandsdal

Hi!

I'm stuck on a little problem...

I want to get te article heading-text and teaser from
http://www.avisa-valdres.no and display it on another page using asp code...

An example on this: www.valdres.no is picking news from www.avisa-valdres.no
and displaying it on valdres.no...

How can I do this with ASP/VBScript code??
Any idea?

The code on valdres.no wich pics the content is made in iHTML, so that does
not help me much ;)

regards
Christopher Brandsdal
Norway
 
C

Christopher Brandsdal

Thanks!

But there is only one more problem...
When I grab a site containing the norwegian characters æøå, it does not
understand the characters. Is there any way I can get it to understand æøå?
 
E

Evertjan.

Christopher Brandsdal wrote on 13 jul 2004 in
microsoft.public.inetserver.asp.general:
When I grab a site containing the norwegian characters æøå, it does
not understand the characters. Is there any way I can get it to
understand æøå?

I do not understand "understand", since a programme is not understanding
anything.

Perhaps:

s = "æø"

s = replace(s,"æ","ae")
s = replace(s,"ø","[slashed o]") ' or whatever
 
C

Christopher Brandsdal

http://forums.devarticles.com/archive/t-3992

see this link to understand what I mean....

Evertjan. said:
Christopher Brandsdal wrote on 13 jul 2004 in
microsoft.public.inetserver.asp.general:
When I grab a site containing the norwegian characters æøå, it does
not understand the characters. Is there any way I can get it to
understand æøå?

I do not understand "understand", since a programme is not understanding
anything.

Perhaps:

s = "æø"

s = replace(s,"æ","ae")
s = replace(s,"ø","[slashed o]") ' or whatever
 
C

Christopher Brandsdal

found the solution myself :)

<%
'function for reading "non-english" charachters
Function BinToText(varBinData, intDataSizeInBytes)
Dim objRS
Const adFldLong = &H00000080
Const adVarChar = 200
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Fields.Append "txt", adVarChar, intDataSizeInBytes, adFldLong
objRS.Open
objRS.AddNew
objRS.Fields("txt").AppendChunk varBinData
BinToText = objRS("txt").Value
objRS.Close
Set objRS = Nothing
End Function

Function GetHTML(strURL,strStart,strEnd)
Dim objXMLHTTP, strReturn, strHTML
Set objXMLHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP")
objXMLHTTP.Open "GET", strURL, False
objXMLHTTP.SetRequestHeader "content-type","text/html;charset=ISO-8859-1"
objXMLHTTP.Send
strHTML = BinToText(objXMLHTTP.responseBody, 4800)
Set objXMLHTTP = Nothing

Dim st,en
st=Instr(strHTML,strStart)
If st<>0 Then
st=st+Len(strStart)
en=Instr(st,strHTML,strEnd)
strReturn=Mid(strHTML, st, en-st)
Else
strReturn="Ingen driftsmeldinger tilgjengelig."
End If
GetHTML = strReturn
End Function

'*****************----- MY CONFIG SECTION START -----*****************
dim URLsnatch, HTMLsBlock, HTMLeBlock
'Webpage to scrape
URLsnatch = "http://www.avisa-valdres.no/default.asp"
'Where to start scraping the webpage
HTMLsBlock = "<! Hovedkolonne ->"
'Where to end scraping the webpage
HTMLeBlock = "<! Vertikal skille 2 ->"
'******************----- MY CONFIG SECTION END -----******************
'Write it:
Dim grabbedText
grabbedText = GetHTML(URLsnatch,HTMLsBlock,HTMLeBlock)
%>

<%=grabbedtext%>


Christopher Brandsdal said:
http://forums.devarticles.com/archive/t-3992

see this link to understand what I mean....

Evertjan. said:
Christopher Brandsdal wrote on 13 jul 2004 in
microsoft.public.inetserver.asp.general:
When I grab a site containing the norwegian characters æøå, it does
not understand the characters. Is there any way I can get it to
understand æøå?

I do not understand "understand", since a programme is not understanding
anything.

Perhaps:

s = "æø"

s = replace(s,"æ","ae")
s = replace(s,"ø","[slashed o]") ' or whatever
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,477
Members
44,898
Latest member
BlairH7607

Latest Threads

Top