Web browser question

S

Sharad Naik

Hello Tim,

In your code, just remove the line 'ifp.Click'
and in its place insert following two lines

Set ifp = ieAlphaTrade.Document.all.Item("loginForm")
ifp.Submit

(i.e. you enter username and password through your code as per your code.
then submit the form, which invokes the 'Post' method on the web site and
you go through)

Sharad
 
T

Tim Coddington

Woah!! Thanks Mr Naik!! And this after all hope had been lost.
Works great for this first part.

-Tim
 
T

Tim Coddington

Did you see where he got the 'loginForm' from? It is the 'name' from the
'<form method="POST"' section. I found it successfully on the next
automatic login I just tried tonight. (You can tell, it's the simple things
that get me going.)
 
S

Shetty

In fact, Ihave seen the loginform while conducting some trials. But I
tried to use ipf.click and other combinations which did not work.
Thanks,
Shetty.
 
B

braindead

Tim, Shetty, Sharad, RV,

Thank you, thank you, thank you!! I have been trying to accomplish just
this task (automating Yahoo Finance webpages navigation via vba) and had
given up just about all hope until I discovered this site and this
thread. Being still very new to vba, you all saved me countless hours of
additional trial and error and hunting for info on the web.

That said, I hope some of you are still monitoring this thread because,
of course, I have a couple questions:

ipf.Click

provokes an error -- I got around it by using

Application.SendKeys "~", True

but that makes me nervous because everything I read about SendKeys tells
me it's unreliable. Any sugqestions on clarifying or modifying the Click
event?

Also, my goal is to copy data off the YF pages and into an Excel
spreadsheet. I don't even care about specifying the data to copy, the
whole webpage will do just fine. If I understand correctly, a Web Query
won't work -- or will it? So again, I think I can use the SendKeys, but
is there a more reliable way?

I'm also trying to accomplish the same thing on another website which
does use the Post method for logging in that Tim referenced. Any success
on figuring that one out?

Finally, the latter website uses pull down menus to navigate to other
pages within the site (vs. Yahoo Finances hyperlinks). Can anyone show
me some basic code examples for navigating this type of website
navigation?

Oh, and one more, mostly curiosity question at this point. Can all this
also be accomplished through WebBrowser ActiveX control on a UserForm?
It seems like a handy resource to take advantage of.

Again, thanks so much for all the help!

Regards,

Brian
 
J

Jake Marx

Hi Brian,

I'm not sure what thread you're referring to, as I'm posting directly to the
MS news servers, and I don't see the initial thread. That said, a webquery
should do what you want here. Since finance.yahoo.com relies on querystring
values (you can see the stock ticker/etc in the browser's address bar), you
should be able to use webqueries. What I would do is start with a default
webquery (http://finance.yahoo.com/q?s=msft or similar), then you can swap
out the "=msft" for "=<stock ticker>" when needed through VBA (just look at
the QueryTable object's Connection property).

For sites that utilize Javascript or use POST methods in their forms, it
becomes a bit trickier. But you may be able to use XMLHTTP to submit the
"form" data and retrieve the text from the resulting page. Here's a brief
example of how it can be accomplished:

http://groups-beta.google.com/group...read/thread/df758293683f18fb/68829784b4ad0c6b

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
B

braindead

Hi Jack,

Thanks for the suggestion. Problem is that the webpages I need to access
within Yahoo Finance have addresses that are relevant only once signed
into the site. Also querystring values but ones that refer to webpages
containing specifically compiled tables (mutual fund models of stocks
within each fund). Entering these addresses into a web query just
produces the YF login page (unlike individual stock pages that do work
as you noted).

This is why I'm working on automating the login (then I can hopefully
navigate to the useraccount-relevant pages and copy the tables into a
spreadsheet). Problem then with a webquery is that it always opens a new
browser window, so even if I manually login to YF, the subsequent
webquery opens in a new window.

As to the javascript and POST methods of the login forms, further
attention to the thread I referenced (http://www.developersdex.com
"Re:Web browser question") did in fact reveal the solutions to
automatically logging in by using the login page's form data for
username, password, etc.

Now I'm trying to work out the kinks of navigating to the next webpage.
It worked a few times but I can't get it to be consistent.

Thanks again,

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top