0

I am using VS 2019 and developing a winform applicaion using VB.Net. I want to get the elements of a webpage into a string so that I can extract the required value from that string.

The following are my Imports - Imports System.IO Imports System.Net

I had put a button on a form for initiating the process. As I was debugging the function, when it came to the line "Dim response As HttpWebResponse = request.GetResponse()" it just loads the form back and does not proceed to the next line.

May I seek help on this? Thanks in advance.

I went through Download contents of webpage with VB and tried to implement the answer given.

I also prefixed the request and response with "Net." as mentioned there. But still the results are same.

  • I am giving an example of the URL below: – Varadarajan R Jan 09 '23 at 12:49
  • "https://www1.nseindia.com/live_market/dynaContent/live_watch/get_quote/GetQuote.jsp?symbol=RELIANCE&illiquid=0&smeFlag=0&itpFlag=0" – Varadarajan R Jan 09 '23 at 12:50
  • During debugging I noticed that the error displayed is "Exception thrown: 'System.Net.WebException' in System.Net.WebClient.dll". – Varadarajan R Jan 09 '23 at 13:05
  • Sorry for keeping on posting comments. I felt additional information will help in identifying the problem. When I use the URL in the browser, the page loads instantly. There is no problem. – Varadarajan R Jan 09 '23 at 13:12
  • 1
    To get the dynamic content of a web page, you need a WebBrowser that executes the scripts. HttpClient / WebRequest don't do any of that, of course. You get the raw html only – Jimi Jan 09 '23 at 13:50
  • For the suggestion given, should I add a WebBrowser control in the form? – Varadarajan R Jan 09 '23 at 17:03
  • If you don't need to show anything, you can use a head-less Browser (i.e., don't use the Control, just the class), make it navigate to the address and get the scripted HTML when the Document you're interested in is complete (specific events are raised to notify this state, but different in, e.g., the WebBrowser Control and WebView2 <- the one you should be using) – Jimi Jan 09 '23 at 21:15

0 Answers0