Home > Forum Home > Automating Data Analysis Tasks > Automating a web query login to download data Share

Automating a web query login to download data

Excel Help for Automating A Web Query Login To Download Data in Automating Data Analysis Tasks


Forum TopicPost Reply Login

Automating A Web Query Login To Download Data

Rate this:
(2.8/5 from 16 votes)
Confused I have a funamental earnings and valuation model spreadsheet that downloads stock data from a number of different websites via certain add-ins.  One of the sites that it gets information from is investors.com, which requires a login before downloading stock information (not just price/volume/etc data, I get that easily from Yahoo).  Problem is that you have to manually login through a web query each time, and this is the current instructions:
  1. Go to "Data" on the Menu bar, then "Import External Data"
  2. Then go to "New Web Query" and a web browser will open
  3. Navigate to www.investors.com and login clicking remember me
  4. Then exit from the query, now you can use this tab
My question is how can I automate the login via either a macro or VBA code to login based upon a user name in one cell (C1), and a password in another cell (C2)?

Thanks in advance for any help you can provide! 
 Posted by on
 
Replies - Displaying 31 to 40 of 40Order Replies By: Most Recent | Chronological | Highest Rated
ConfusedHi,
I am trying to mak a macro to log in to [http://metflight.metra.co.nz/MetFlight.php] then once the pop up has loaded, select certain parameters, then from a following pop up window, copy and paste that data in excel.  Can anyone help me? I have tried using a few different ways to just log in, but im struggling wth that. 
 Posted by on
Confused
Rate this:
(3/5 from 1 vote)
I have copied and pasted the first VBA code (first I have created an account in business-spreadsheet site), but it did not worked. Data os site was transferred to Excel, but looking at H11 cell I noticed that it is written Login instead of logout, so login did not worked.
Does VBA code really works for POST method?
 Posted by on
Confused
Rate this:
(3/5 from 1 vote)
I have discovered that site has changed, so I was able to import data adding "&log=1" as the third parameter.
 Posted by on
Confused
Rate this:
(3/5 from 1 vote)
Hi,
After reading all these post, i tried, but is not working in my requirement . i want download Traffic fine from [http://www.rta.ae/wpsv5/wps/portal] -Fine Inquiry- put the Traffic File number(50086190) and click search and download. Could any one help me on this, it would be really appreciated.

Thanks
Abdul Jaleel
 Posted by on
Surprised
Rate this:
(3/5 from 1 vote)
Hi,
I receive a logon screen from whitch I can not right click to see the parameters required. Looks like a windows login screen. Can anyone help with this ?
Regards
Bernard


 Posted by on
Confused
Rate this:
(3/5 from 1 vote)
+1 right here.
 Posted by on
Surprised
Rate this:
(3/5 from 6 votes)
On analysis of the web site in question, the form variable names to login are htmUserName and htmPassword.

In this case, the primary task is to replace the three constants like:

VBA Code:
Const MyUrl As String = "http://www.investors.com/login.aspx?/default.asp"
Const PostUser As String = "htmUserName=User Name" 'Change user name here
Const PostPassword As String = "&htmPassword=password" 'Change password here


Note that, you may be able to change the URL and add more variables in order to download the data in one step without having to first login.
 Excel Business Forums Administrator
 Posted by on
Happy
Rate this:
(2.7/5 from 15 votes)
You can post form variables to a web query in order to automatically login to a page and retrieve its data.  You need to know the name of the form variables required by the page.  This information can be obtained by right cliking of the page that requires the information and chossing to "View Source".  The names of the form variables that are required to be posted are the values of the "name" attributes for the elements within the "form" tag.

The following VBA code shows how to login into this forum and access this post:

VBA Code:
Sub Login_WebQuery()
Dim MyPost As String
Const MyUrl As String = "http://www.business-spreadsheets.com/forum.asp?t=103"
Const PostUser As String = "login=User Name" 'Change user name here
Const PostPassword As String = "&pass=password" 'Change password here
   
MyPost = PostUser & PostPassword
   
With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;" & MyUrl, Destination:=Cells(1, 1))
    .PostText = MyPost
    .BackgroundQuery = True
    .TablesOnlyFromHTML = True
    .Refresh BackgroundQuery:=False
    .SaveData = True
End With
   
End Sub

 Excel Business Forums Administrator
 Posted by on
Confused
Rate this:
(2.2/5 from 4 votes)
Good code!

But I have this webpage, RECOM (Register Of Commerce):
http://recom1.onrc.ro/cgi-bin/recom.cgi?o7=1&l=R

I want to insert a CUI (Unique Identification Number -- of a Company) in the CUI field a return the result page.

A valid CUI number is: 15413161

So sticking 15413161 into CUI field and pressing "Selectie" should return a page wich will validate me or not the Company's Identification Number.

How can I adapt the code above for my case?

Thank you very much! :)

 Posted by on
Confused
Rate this:
(2/5 from 3 votes)
Hi, I am new to creating macros and I want to create a macro that automatically log in the website and take the user to the desired page.
For Example, Suppose I want to login to [http://www.yahoomail.com/] The functionality of macro should be such that it prompts the user for the username and password and passes the same to the login page of the website and if the credentials are valid then it logs in the user to the website.

Please let me know if this can be done and suggest a wayout if possible.
 leena
 Posted by on
 Displaying page 4 of 5 

Find relevant Excel templates and add-ins for Automating a web query login to download data in the