0

I've tried this so far:

Dim wreq As HttpWebRequest = WebRequest.Create("http://www.nasdaq.com/symbol/goog/financials?query=income-statement&data=quarterly") wreq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5" wreq.Method = "get" Dim prox As IWebProxy = wreq.Proxy prox.Credentials = CredentialCache.DefaultCredentials Dim document As New HtmlAgilityPack.HtmlDocument Dim web As New HtmlAgilityPack.HtmlWeb web.UseCookies = True web.PreRequest = New HtmlAgilityPack.HtmlWeb.PreRequestHandler(AddressOf onPreReq) wreq.CookieContainer = cookies Dim res As HttpWebResponse = wreq.GetResponse() document.Load(res.GetResponseStream, True) Debug.WriteLine(document.DocumentNode.OuterHtml) 

But it returns the HTML for this web address: http://www.nasdaq.com/symbol/goog/financials?query=income-statement

Instead of this one: http://www.nasdaq.com/symbol/goog/financials?query=income-statement&data=quarterly

What am I doing wrong?

Additional Info

Here is onPreReq

Private Function onPreReq(req As HttpWebRequest) req.CookieContainer = cookies Return True End Function 
12
  • 1
    Just sounds like your data argument isn't getting passed. Maybe try it like this - stackoverflow.com/a/17219511/1454048 Commented Nov 7, 2013 at 16:45
  • 1
    I haven't tried your code (I will later if I get time), but basically: the difference between your two web addresses is just the &data=quarterly part, which seems to be ignored, right? That's just an extra argument that's part of a standard HTTP GET request. Try using the method in the link I put above, see if that helps. Commented Nov 7, 2013 at 17:48
  • 1
    Is there something in onPreReq that is changing the address. I dont have the HtmlAgilityPack so I commented out some code and added in some other and it looked correct. Commented Nov 7, 2013 at 21:13
  • 1
    So if you click on the link you posted above, it brings you to another site? Strange. Note, I also did not use the cookies in my test because your code is incomplete. Perhaps the cookies are doing it to you, or the web site is redirecting you because you have been hitting it too much. I've seen that before. Unlikely because they just directed you to the wrong financials page. They would usually redirect you to some HTML page that says your doing something against thier policies. Commented Nov 7, 2013 at 21:31
  • 1
    1: I think admdrew was just pointing out the obvious between your 2 links. I dont believe you are doing it wrong. 2: I dont know what is in your cookies or how the website uses them. Try not passing them and see what happens. 3: All else fails, try your code on another computer on another public IP (ie, at a friends house) and see if it works. If so, the website is jacking you around because of the number of hits. Commented Nov 7, 2013 at 21:47

1 Answer 1

0

The problem was with my variable Ticker. It contains the ticker symbols that I use to create the web addresses. I have been using all caps (ex. GOOG) up to this point. I've changed all of my tickers to lower case (ex. goog) and that seems to have done the trick.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.