473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Opening a file over the internet

My final goal is to laod the source of an HTML page displayed at a given URL
and through a buffer to save it into a database. If that file would be local,
the code would be:

Dim fs As FileStream
Dim sPath as String = "C:\Test.htm"
fs = File.OpenRead(sPath)
Dim buffer(fs.Length) As Byte
fs.Read(buffer, 0, fs.Length)

and from buffer I would insert that file into the database.
My problem is that File.OpenRead() does not accept as argument an URL.
Could someone help me figure how can I read the source of a WEB page (as a
HTML file) in order to save it into my database.

Thanks in advance,
Nov 21 '05 #1
3 1935
Hi,

Webclient.OpenRead

http://msdn.microsoft.com/library/de...nreadtopic.asp

Ken
------------------
"Adrian" <ab*****@noemail.nospam> wrote in message
news:73**********************************@microsof t.com...
My final goal is to laod the source of an HTML page displayed at a given URL
and through a buffer to save it into a database. If that file would be
local,
the code would be:

Dim fs As FileStream
Dim sPath as String = "C:\Test.htm"
fs = File.OpenRead(sPath)
Dim buffer(fs.Length) As Byte
fs.Read(buffer, 0, fs.Length)

and from buffer I would insert that file into the database.
My problem is that File.OpenRead() does not accept as argument an URL.
Could someone help me figure how can I read the source of a WEB page (as a
HTML file) in order to save it into my database.

Thanks in advance,
Nov 21 '05 #2
Adrian,

As alternative
\\\\
Module main
Public Sub main()
Dim myReg As Net.HttpWebRequest = _
DirectCast(Net.WebRequest.Create("http://www.google.com"), _
Net.HttpWebRequest)
Dim myResp As Net.HttpWebResponse = _
DirectCast(myReg.GetResponse(), Net.HttpWebResponse)
Dim myStream As IO.Stream = myResp.GetResponseStream()
Dim myreader As New IO.StreamReader(myStream)
Dim mystring As String = myreader.ReadToEnd()
myResp.Close()
End Sub
End Module
///
I hope this helps a little bit?

Cor
Nov 21 '05 #3
"Adrian" <ab*****@noemail.nospam> schrieb:
My final goal is to laod the source of an HTML page displayed at a given
URL
and through a buffer to save it into a database. If that file would be
local,
the code would be:

Dim fs As FileStream
Dim sPath as String = "C:\Test.htm"
fs = File.OpenRead(sPath)
Dim buffer(fs.Length) As Byte
fs.Read(buffer, 0, fs.Length)

and from buffer I would insert that file into the database.


\\\
Imports System.IO
Imports.System.Net
..
..
..
Public Function LoadTextFile(ByVal Url As String) As String
Dim wrq As WebRequest = WebRequest.Create(Url)
Dim wrp As HttpWebResponse = _
DirectCast(wrq.GetResponse(), HttpWebResponse)
Dim sr As New StreamReader(wrp.GetResponseStream)
Dim Text As String = sr.ReadToEnd()
sr.Close()
wrp.Close()
Return Text
End Function
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Hari Prasad | last post by:
Hi, I have downloaded some image files by connecting to a URL and I am trying open that image file using BrowserLauncher. I am using windows xp and the default one to open image files is windows...
44
by: Carlos Andr?s | last post by:
Hi everybody. I've got a problem. I'd like to avoid opening a new window when you have pressed the shift key and you click in the left button of the mouse. I've tried the next solution, in the...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
2
by: ChrisR | last post by:
Hi folkes I have a simple html file with 2 frames, as my Help file to my DB. It consists of 3 parts: Help.htm = Is the main file with the 2 frames. Index.htm = Is the left frame as a index...
2
by: Matt Hamilton | last post by:
I have an application page with a datagrid with a checkbox on each row. The user should check the rows they want to modify and then click a button. When the button is clicked, I have a Click...
6
by: Kenneth P | last post by:
Hi, It's rather common today, to see a PDF opening within a new Internet page. But how is it done in ASP.NET, VS2003? I'd rather use it as a way to invoice electronically. You email your...
1
by: celoftis | last post by:
BACKGROUND: I have some PPT slides that have been converted to HTM (ensuring that the show slide animations while browsing checkbox is checked). The original HTM slides have custom animations to...
1
by: T | last post by:
Currently there is an excel shortcut available on the network with links to 30 or so access db (97 & 2003), since the users are complaining about all the messages from excel (already open, do you...
1
by: santoshmaya | last post by:
When opening a PDF over SSL running on IIS 5.1 (Windows XP Professional, W2K Windows 2000, or Windows Server 2003), you may receive the following problem with Internet Explorer. First, instead of...
0
by: mraja1977 | last post by:
Hi All, I am writting/opening different types file data to the browser by using following code in c#. for all type of files there wont be any problem, but in case of html file, when i tries...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.