ASP to ASP.NET

G

Guest

Can someone please tell me how I do something like this in ASP.NET!

I have the following ASP script that pulls part of a webpage from one
website and then inserts that into my site!

How do you do this in ASP.NET

Thanks for any help!

I'm a little stuck with this!


<%
Dim StrURL
Dim StrHTML
Dim ObjWeather
StrURL1 = "http://weather.lycos.com/?q="&("Copenhagen, Denmark")

StrURL =
"http://weather.lycos.com/weather/seven_day_forecast.asp?q="&("Copenhagen,
Denmark")

strmetric="http://weather.lycos.com/weather/setprefs.asp?units=metric"

If Not "Copenhagen, Denmark" = "" Then
Set lObjWeather = Server.CreateObject ("Microsoft.XMLHTTP")
If Err Then
GetURLm = "Error: " & Err.Description
End If

On Error Goto 0
With lObjWeather
.Open "GET", strmetric, False, "", ""
.Send
GetURLm = .ResponseText
End With
Set LobjWeather = Nothing
strHTMLm = GetURLm

end if
If Not "Copenhagen, Denmark" = "" Then
Dim strText

On Error Resume Next
Set lObjWeather = Server.CreateObject ("Microsoft.XMLHTTP")
If Err Then
GetURL1 = "Error: " & Err.Description
End If
On Error Goto 0

With lObjWeather
.Open "GET", StrURL1, False, "", ""
.Send
GetURL1 = .ResponseText
End With
Set LobjWeather = Nothing

strHTML1 = GetURL1

end if

If Not "Copenhagen, Denmark" = "" Then
Dim strText1

On Error Resume Next
Set lObjWeather = Server.CreateObject ("Microsoft.XMLHTTP")
If Err Then
GetURL = "Error: " & Err.Description
End If
On Error Goto 0
With lObjWeather
.Open "GET", StrURL, False, "", ""
.Send
GetURL = .ResponseText
End With
Set LobjWeather = Nothing
strHTML = GetURL
end if
%>
<%
If Not "Copenhagen, Denmark" = "" Then
StrHTML = GetURL
myarr=split (StrHTML,"<!-- BeginMainColumn -->", -1, 1)
myarr2=split (myarr(3),"<!-- EndMainColumn -->", -1, 1)
stringu=myarr2(0)
Response.Write stringu
'Response.Write Replace(Server.HTMLEncode(stringu), vbCrLf, "<BR>")
End If
%>
 
K

Kevin Spencer

Okay, let's say you have a volume of the Encyclopedia Britannica. It's
written in English. You want to translate it to Danish. How would you go
about doing that? Well, you could ask a person that speaks both Danish and
English to do your translation for you, or you could learn Danish.

In this case, you have only one volume of the Encyclopedia, and plan to
translate other volumes in the future. Your Danish-speaking friend isn't
likely to continue translating for you indefinitely, so your best bet is to
learn Danish.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
G

Guest

Clever answer!

Problem is I'm learning to speak Danish... I just don't know what Namespace
I should be using in ASP.NET to do the samething as the ASP code does below!

So if you know I would appritiate your help! If not then can someone else
please suggest how I can achive this!

Thanks...
 
C

Craig Deelsnyder

Clever answer!

Problem is I'm learning to speak Danish... I just don't know what
Namespace
I should be using in ASP.NET to do the samething as the ASP code does
below!

So if you know I would appritiate your help! If not then can someone else
please suggest how I can achive this!

Thanks...

You need to look at HttpWebRequest and HttpWebResponse; they allow you to
make a request for a page from a remote server, and you get the response
(HTML, etc.), so you are acting just like a browser. Here's a very simple
example:

http://www.codeproject.com/csharp/dcweatherupdate.asp

Here's a more complicated example, in that it looks like the author
created a custom class to wrap up this functionality with authentication
capability, etc.

http://www.codeproject.com/csharp/HttpWebRequest_Response.asp
 
G

Guest

Thanks for the reply Craig!



Craig Deelsnyder said:
You need to look at HttpWebRequest and HttpWebResponse; they allow you to
make a request for a page from a remote server, and you get the response
(HTML, etc.), so you are acting just like a browser. Here's a very simple
example:

http://www.codeproject.com/csharp/dcweatherupdate.asp

Here's a more complicated example, in that it looks like the author
created a custom class to wrap up this functionality with authentication
capability, etc.

http://www.codeproject.com/csharp/HttpWebRequest_Response.asp
 

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,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top