Excel web query to login into a website

0 votes

There are two different passwords on the page, thus I'm seeking for a macro or vba code to log me in. I've got some code that uses Internet Explorer to access websites, but it doesn't retrieve data because the web query browser is not logged in and I'm only logged into Internet Explorer, not the excel web query browser. As a result, I can't use my previously created web query connections to refresh or update data in Excel.

Sub WebLogin()
Dim a As String
Set IE = CreateObject("InternetExplorer.Application")
With IE
    .Visible = True
    .Navigate "https://newtrade.sharekhan.com/rmmweb/login/LoginPage.jsp"
    Do Until .ReadyState = 4
        DoEvents
    Loop
    .Document.all.Item("loginid").Value = "myuserid"
    .Document.all.Item("brpwd").Value = "password1"
    .Document.all.Item("trpwd").Value = "password2"
    .Document.forms(0).submit
End With
IE.Quit
End Sub

Is there a way to update this code so that it uses the Excel Web Query Browser instead of Internet Explorer and can auto-log in with only a simple refresh of the external web connection that is already attached to my Excel sheet?

Sep 20, 2022 in Others by Kithuzzz
• 38,020 points
2,821 views

1 answer to this question.

0 votes
To be recognized by the web server in subsequent requests, you must obtain the cookie after signing in. Always login first in order to get that variable from the browser.

Grab the necessary cookies once you log in using the code you posted (try simulating your attempt in Internet Explorer using Network Recorder in the developer tools of the browser). After exiting IE, you can send those cookies to the server in the HTTP Post request.
answered Sep 21, 2022 by narikkadan
• 63,720 points

Related Questions In Others

0 votes
1 answer

How to import data from a HTML table on a website to excel?

Hello  To import any HTML file in excel there ...READ MORE

answered Feb 10, 2022 in Others by gaurav
• 23,260 points
7,709 views
0 votes
1 answer

How to unmerge multiple cells and transpose each value into a new column in Pandas dataframe from excel file

Try this: df = pd.read_excel("Sample_File.xlsx", header=[0,1,2,3,4,5], index_col = ...READ MORE

answered Jan 8, 2023 in Others by narikkadan
• 63,720 points
2,416 views
0 votes
1 answer

How to represent the data of an excel file into a directed graph?

The pandas and networkx packages in Python ...READ MORE

answered Apr 9, 2023 in Others by narikkadan
• 63,720 points
1,845 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,106 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,537 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
828 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
986 views
0 votes
1 answer

How to insert a picture into Excel at a specified cell position with VBA

Try this: With xlApp.ActiveSheet.Pictures.Insert(PicPath) With ...READ MORE

answered Oct 24, 2022 in Others by narikkadan
• 63,720 points
2,419 views
0 votes
1 answer

Trying to create an enclosing bookmark after pasting a picture from Excel into Word using VBA

Try this: Sub IMPORT_TO_WORD() Dim ws1 As Worksheet, ws2 ...READ MORE

answered Oct 30, 2022 in Others by narikkadan
• 63,720 points
840 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP