Question Copy the Contents from a web page and write it in a word/excel file

Sandhiya

New member
Joined
Aug 16, 2012
Messages
2
Programming Experience
Beginner
Hi everyone,
I would like to copy the contents in a web page and write it in the word or excel file.
Say for example
If I give the URL of a web page then the system has to extract the content of that web page and write it in a word file or excel file.
I tried with the following code but I could only get the "Source Code" of the web page but I am in need of the contents.

Imports System.Net
Public Class Qwerty

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Using wc As New WebClient()
Dim myString
myString = wc.DownloadString(address:="http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx#Y114")
Dim myfile As String = "D:\test.doc"
Dim objWriter As New System.IO.StreamWriter(myfile)
'Write string:
objWriter.Write(myString)
'Close objectwriter:
objWriter.Close()
End Using
'Succes:
MessageBox.Show("Writing succesful!")
End Sub

Any help ............???
 
What do you mean by contents?

It's all there in the file, you just have to extract it from the HTML

perhaps your mistake is to open it in Word - not the best place for an HTML file...
 
What do you mean by contents?

It's all there in the file, you just have to extract it from the HTML

perhaps your mistake is to open it in Word - not the best place for an HTML file...


Thanks for replying,,,,,And content in the sense the text that appears in the front end....
But as per my code i could get the source code with HTML tags...
If that is the case then is it possible to write it in the *.txt file.
 
Thanks for replying,,,,,And content in the sense the text that appears in the front end....
But as per my code i could get the source code with HTML tags...

so you need to use a FOR...NEXT loop through the text and remove the html tags before you output it to the file.

If that is the case then is it possible to write it in the *.txt file.

I assume by that you mean is it possible to write the output to a text file. of course it is, just alter the code... please don't tell me you do not know how to write the output to a text file instead of a word document!
 

Latest posts

Back
Top