473,396 Members | 1,942 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,396 software developers and data experts.

How to retrieve data from a website

I want to retrieve data from a website based on a file number.But i have to do this programmatically using vb.net and finally have to store the results in a csv file.
In my web application,i will give the file number in a textbox(through GUI) and the site address(through vb.net code) and when i click the search button,the csv output should be obtained.
I am fed up with this problem for the last 2 weeks..can anybody pls help me in this situation.

Thanks & Regards,
rinu
Dec 2 '08 #1
14 4182
anijos
52
You can use a datatable to save the data first and later convert it into .csv format.
Dec 2 '08 #2
hi anijos,
Thanx for ur quick reply..but i didnt get the first part itself..i.e,i am not able to access the site through vb.net code(i dont want to open the site in my page)and also i am not getting the search results of the particular file no. in my page

Hope u got it..pls help me
Dec 2 '08 #3
anijos
52
Rinu,

what do u mean by serach result for file no? i dont understand that part.. can you explain a bit more?
Dec 2 '08 #4
hi anijos,
surely..i'll explain that in detail..my intention is to give one traffic file no(e.g.vehiclenumber)in one textbox in my webapplication...on clicking search button it should give the same results as the results from the website(in the third party website...there is a provision for entering the file no..and on search..it will display the results in that site )

I dont want to take the website each and everytime,instead,i'm giving the website address in my vb.net code..and based on the file no. which i'm changing in the textbox,the output should vary..

Did u get it?
Dec 2 '08 #5
anijos
52
Hi Rinu,

I still dont under stand your application. you said something about a third party website rt? can u send me the url for that? may be that will allow me to understand your problem better.

what i've understood till now is,

In a web site when you give a parameter like vehicle no and search, you are getting the details. you want to implement that locally. is my understanding correct?

Thanks
AniJos
Dec 3 '08 #6
Hi anijos
wat u understood is right.yes,i hav to get search results based on the input vehicle no(file no) and finally i hav to store the results in a csv file(i want to do this programmatically in my web applicationusing vb.net or c#).
Pls pardon me for not exposing the url bcos i dont hav the permission for that.Hope u understood my situation.

If any idea is there,pls help me.
regards
rinu
Dec 3 '08 #7
Frinavale
9,735 Expert Mod 8TB
Are you having problems retrieving the information?
Or are you having problems storing the information retrieved into a CVS file?

-Frinny
Dec 3 '08 #8
Hi,
I didnt get the first part itself..(retrieving the information from the website)
I tried a lot with datascraping code,but it didnt work.
I got the html of the website,after that, am not able to get the input tag of the concerned textbox(using getElementsByTagName)
i'm stuck from that onwards.
hope u guys can help me

regards
rinu
Dec 3 '08 #9
Frinavale
9,735 Expert Mod 8TB
Go to the website and look at the HTML code to find out what the name of the input field is.

You're going to have to use the HttpWebRequest to request the page's content (using the GetResponse() method). From there you'll have to parse through the HTML (returned to you in a HttpWebResponse object) and find the input field.

Please look into how to retrieve web content and investigate how to parse that information before continuing to attempt to write anything to a CVS file.

Taking smaller steps will keep you from getting overwhelmed by the problem...and it will make it easier for us to answer your questions.

-Frinny
Dec 3 '08 #10
Hi,
I used HttpWebRequest to request the content of the website and is returned in a HttpWebResponse object.
I got the html of the website,but my problem is,i'm not able to parse through the html of the website(not getting the match of the concerned textbox' input tag).

This code is working properly for website address like "http://www.abc.com"
but can you give me solution for such like (http://www.abc.com/index.php?name=abc&id=123) for user authentication as u give? how can I get the contents from such types of pages.. (I am not able to expose the exact website address..www.abc.com is just given for example)

I am attaching the code :
Expand|Select|Wrap|Line Numbers
  1.  Dim str As String = ""
  2.         Dim uri As New Uri("http://www.abc.com/index.php?name=abc&id=123")
  3.         Dim request As HttpWebRequest = DirectCast(WebRequest.Create(uri.AbsoluteUri), HttpWebRequest)
  4.         request.AllowAutoRedirect = True
  5.         request.MaximumAutomaticRedirections = 5
  6.         request.KeepAlive = True
  7.         request.Timeout = &H7530
  8.  
  9.         Dim response As HttpWebResponse = Nothing
  10.         Try
  11.            response = DirectCast(request.GetResponse, HttpWebResponse)
  12.         Catch exception1 As WebException
  13.             literal1.Text = exception1.Message
  14.         End Try
  15.  
  16.  
  17.         Dim reader As StreamReader = Nothing
  18.         Try
  19.             Dim encoding As New UTF8Encoding
  20.             reader = New StreamReader(response.GetResponseStream, encoding)
  21.             str = reader.ReadToEnd
  22.             literal1.Text = str
  23.         Catch exception As Exception
  24.             literal1.Text = exception.Message
  25.         End Try
  26.  
Thanx
Rinu
Dec 6 '08 #11
anijos
52
Try

request.Credentials = new NetworkCredential(username, password);

AniJos
Dec 9 '08 #12
Frinavale
9,735 Expert Mod 8TB
@anijos
:) This has already been covered, from what I understand NetworkCredentials don't work with Forms Authentication.
Dec 9 '08 #13
Hi..
I am still fed up with the problem,as I said earlier,i got the html of the website,but i'm not able to get the match for that input tag from this html,I tried the code below:
Expand|Select|Wrap|Line Numbers
  1. HTMLDoc = wbBrowser.Document
  2.  
  3.         Dim iHTMLCol As IHTMLElementCollection
  4.         Dim iHTMLEle As IHTMLElement
  5.        ''HTMLDoc.focus()
  6.  
  7.         iHTMLCol = HTMLDoc.getElementsByTagName("input")        ' Type the Traffic file no in  the TrfNo text box  
  8.  
  9. '(when i am trying to get HTMLDoc.getElementsByTagName("input").length..it is returning 0,eventhough so many input tags r there)
  10.         For Each iHTMLEle In iHTMLCol
  11.             If Not iHTMLEle.getAttribute("name") Is Nothing Then                             str = iHTMLEle.getAttribute("name").ToString
  12.                 If str = "TrfNo" Then 
  13.                     iHTMLEle.setAttribute("value", 1234)
  14.                 End If
  15.                 Exit For
  16.             End If
  17.         Next         
  18.  
  19.  
  20. ' Press the submit button
  21.  
  22.          For Each iHTMLEle In iHTMLCol
  23.             If Not iHTMLEle.getAttribute("name") Is Nothing Then
  24.  
  25.                If iHTMLEle.outerHTML = "<INPUT type=SUBMIT" & _
  26.                                         "name=btnG" & _
  27.                                   "value=Search> " Then
  28.                    'document.forms[0].submitBttn.click()
  29.                    iHTMLEle.click()
  30.                  Exit For
  31.               End If
  32.           End If
  33.         Next
  34.  
  35.        Do
  36.         Loop Until Not wbBrowser.Busy
Dec 11 '08 #14
Ramk
61
Plz use [code] tags for when you are posting code.

Try using this:
Expand|Select|Wrap|Line Numbers
  1.  
  2. HtmlDocument.GetFilteredHtmlTags()
  3.  
Dec 11 '08 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: nyousfi | last post by:
Hi everyone, I hope you can help! I have the following query accesing an SQL Server 2000 Box SELECT website.websiteID, website.description, website.URL, website.DepartmentID
2
by: PDXWilliam | last post by:
Hello, I'd really appreciate help on this. I'm programmatically retrieving data from a website and on one particular page, I'm figure out what I should be sending to grab this data. Please...
3
by: Mal Reeve | last post by:
Hello, I am looking for an easy way to retrieve a file from a given website.. I am building an app that will retrieve a .csv file then TRANSFER text it into a table for further processing.. ...
2
by: will | last post by:
hi, my ISP doesn't have webmail service, so i use TcpClient & Friends to issue POP3 commands to retrieve emails, store data on a website, and use that website to view emails. it all works...
5
by: Roy Gourgi | last post by:
Hi, I am used to working in Visual FoxPro and I would like to be able to create a database and store and retrieve information from it. What is the simplest way to do it and what should I be...
0
by: Hexman | last post by:
Hello All, Its a bit more complicated than the subject line implies. A website that I use for information allows me to click on a link and their .PDF displays in IE's browser window.. Since...
0
by: padhuwork | last post by:
Hi, I want to create a Windows DLL using VC++ 6.0 which connects to SQL Server. After establishing the connection, I want to retrieve records from table (query) and out put the recordset to a...
1
by: deepaks85 | last post by:
Dear Sir, Is there any way to Get / Retrieve data from any website? I want the contents from a website into my website so that the contents can automatically update if the contents get changed...
3
by: John0111 | last post by:
Hello Everybody, I am sure somebody would be able to help me, I will be forever in your debt :) Here is the scenario, I have a website and say for this sake it is a profile database basically....
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.