ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to find username/passowrd controls (https://www.excelbanter.com/excel-programming/433023-re-how-find-username-passowrd-controls.html)

joel

how to find username/passowrd controls
 
It is a usually userform. I look at the source html usiing by going to the
internet explorer and using the menu view - source. the internet explorer 8
under tools - developer tools you can see the tag items.

You need to either find the Tag associated with the login or the "id=". If
you give me the webpage URL I will get you the username and login code.

the code below is similar to a login window and will give yo a good idea how
this is accomplished

Sub GetZipCodes()


ZIPCODE = InputBox("Enter 5 digit zipcode : ")

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

URL = "http://zip4.usps.com/zip4/citytown_zip.jsp"

'get web page
IE.Navigate2 URL
Do While IE.readyState < 4 And _
IE.busy = True

DoEvents
Loop

Set Form = IE.document.getElementsByTagname("Form")

Set zip5 = IE.document.getElementById("zip5")
zip5.Value = ZIPCODE


Set ZipCodebutton = Form(0).onsubmit

Form(0).submit
Do While IE.busy = True
DoEvents
Loop

Set Table = IE.document.getElementsByTagname("Table")
Location = Table(0).Rows(2).innertext
IE.Quit
MsgBox ("Zip code = " & ZIPCODE & " City/State = " & Location)


End Sub



"thomas donino" wrote:

I need to navigate to a webpage, and login with user and pass.
How do I know what the webpage is looking for for the username, meaning
user, or username or accountname etc etc
my current code using
variablename.value = "user" is where the code is barfing


thomas donino

how to find username/passowrd controls
 
Joel,
The url is www.elliottwave.com
Thank you for your help

"Joel" wrote:

It is a usually userform. I look at the source html usiing by going to the
internet explorer and using the menu view - source. the internet explorer 8
under tools - developer tools you can see the tag items.

You need to either find the Tag associated with the login or the "id=". If
you give me the webpage URL I will get you the username and login code.

the code below is similar to a login window and will give yo a good idea how
this is accomplished

Sub GetZipCodes()


ZIPCODE = InputBox("Enter 5 digit zipcode : ")

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

URL = "http://zip4.usps.com/zip4/citytown_zip.jsp"

'get web page
IE.Navigate2 URL
Do While IE.readyState < 4 And _
IE.busy = True

DoEvents
Loop

Set Form = IE.document.getElementsByTagname("Form")

Set zip5 = IE.document.getElementById("zip5")
zip5.Value = ZIPCODE


Set ZipCodebutton = Form(0).onsubmit

Form(0).submit
Do While IE.busy = True
DoEvents
Loop

Set Table = IE.document.getElementsByTagname("Table")
Location = Table(0).Rows(2).innertext
IE.Quit
MsgBox ("Zip code = " & ZIPCODE & " City/State = " & Location)


End Sub



"thomas donino" wrote:

I need to navigate to a webpage, and login with user and pass.
How do I know what the webpage is looking for for the username, meaning
user, or username or accountname etc etc
my current code using
variablename.value = "user" is where the code is barfing


ron

how to find username/passowrd controls
 
On Aug 30, 7:46*am, thomas donino
wrote:
Ron,

Works perfectly, but for learning purposes how did you find the string to
replace
.Document.all.Item("name") *with
.Document.all.Item("ewiHeader_ucEwiLogin_userid") ?

I am not that familiar with html coding



I'll identify a word or phrase on the web page that relates to the
login section and then "find" it in the source code. In this case,
"Please Login" works fine. Once in the right general area of the
source code you can see the lines relating to userid, password, etc.
Here's the line in the source code that relates to the userid

<input name="ewiHeader:ucEwiLogin:userid" type="text"
id="ewiHeader_ucEwiLogin_userid" /

It is the "id" portion of this line that identifies the term you want
to use in the "document.all. item" statement. Hope this helps, Ron

ron

how to find username/passowrd controls
 
Whoops!

The two web pages (logged in / not logged in) will be different. One
will have a term like "Please Login", the other won't.
Correspondingly, the source code will or won't have that phrase. So,
try something like

Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.Navigate "www.elliottwave.com/"
Do Until .ReadyState = 4
DoEvents
Loop

my_var = .document.body.innerhtml

if instr(1, my_var, "Please Login", vbTextCompare) 0 then
do your login routine
end if

now do whatever you do after you're logged in

....Ron


thomas donino

how to find username/passowrd controls
 

Ron,

Thanks for all the help. The changes you suggest work great. I can now
navigate around to different pages. I am trying to send a command to print
the pdf's i find to a certain printer. Using the send keys is not working as
I cannot specify the printer name, or at least I don't know how to.

Tom
"Please Login", the other won't., the source code will or won't have So,
try something like

Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.Navigate "www.elliottwave.com/"
Do Until .ReadyState = 4
DoEvents
Loop

my_var = .document.body.innerhtml

if instr(1, my_var, "Please Login", vbTextCompare) 0 then
do your login routine
end if

now do whatever you do after you're logged in

....Ron



ron

how to find username/passowrd controls
 
On Aug 30, 9:13*am, thomas donino
wrote:
Ron,

Thanks for all the help. The changes you suggest work great. I can now
navigate around to different pages. I am trying to send a command to print
the pdf's i find to a certain printer. Using the send keys is not working as
I cannot specify the printer name, or at least I don't know how to.

Tom


Tom...The following line of code will identify the active printer's
name...Ron

current_printername = Application.ActivePrinter




All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com