web page entries

  • Thread starter Thread starter Bassman
  • Start date Start date
B

Bassman

Hello everyone,
I am not sure where to look. this groups has helped in the past so I
thought I would start here.
I have a website that I need to entry part numbers and qty for several
months of sales. On the web page you tab for each entry box and you
can only entry ten rows at a time before you submit for validation.
Each box holds different information such as, part number "b2gt,
5647,a1a" qty of "1" would be,first box "b2gt", second box "5647"
third box "a1a" and forth is the qty "1". My spreed sheet has it
broken down correctly. I can not copy and paste to the page, this puts
everything in same entry box. I need to have it tab after each cell
on the web page. Can I do this? I have been searching for a program/
software. We use some emulation software to do this on our invoices
from our lookup catalog but I am not sure where the program came from.
Do I use macros?
If this is not the correct group I apologize in advance.
 
I need your source html code to be able to help or a link to the page if it
is public. I'm not sure how you generated your webpage that would also help.

I need to find out how each box is identified. You could use a Send Key
command and send a TAB key commend but I would think that would be less
reliable.


If you have any macro code already that would be a bonus.
 
I need your source html code to be able to help or a link to the page if it
is public.  I'm not sure how you generated your webpage that would alsohelp.

I need to find out how each box is identified.  You could use a Send Key
command and send a TAB key commend but I would think that would be less
reliable.

If you have any macro code already that would be a bonus.

It's not my page. It is a company web site. We input our number for
reporting. it is mostly java. What do I need to look for for you?
 
I have two examples of programs below. I use a combination of techniques to
backwards engineer Web code. I don't know Java very well and I'm not
experienced enough to be an expert but I can usally get things to work by
brute force method.

I usally got the webpage using Internet Explorer and use the menu View -
Source which will open a NotePad of the code. I look for two things

1) Tags, tags look like this

start of tag is an angle bracket with the name and the close is
an angle bracket with name and backslash

< A ..............some text ........... /A >

You can get tags in code below using this statement

Set A_Tags = IE.Document.getelementsbytagname("A")


2) I also look in the source code for ID's which are : id =abc

You can get these in code with

'Set ABC = IE.document.getElementById("abc")


The boxes you are looking for should have usique ids which will get you the
locations to put the data.

I also dump all the items to a worksheet (sheet1) like I did in the macro
GenericCode() below. There is a for loop with ITM in this code. I also put
a break point in the for loop and then add ITM to the watch window to help me
debug code. You can change the URL in this code to your website to help you
find the name of the boxes.

In the first Nissan code I added data to a text box using these two lines

Set radius = IE.document.getElementById("radius")
radius.Value = "100"


You need to do something similar in your code.
I hope this will get you started
------------------------------------------------------------------------------------------------

Nissan Dealer code
Make a Worksheet called DEALERS and run this cod
--------------------------------------------------------------------------------------------
Sub GetDealers()
'Dim PageNumber As Object
CR = Chr(13)
LF = Chr(10)

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

URL = "http://www.nissanusa.com/apps/dealerlocator"
Request = "?zipCode=07508&tool=Home.Locator"

'get web page
IE.Navigate2 URL & Request
Do While IE.readyState <> 4
DoEvents
Loop

'get search button
Set but = IE.document.getElementById("mainSearchButton")
'put distance in listbox on webpage
Set radius = IE.document.getElementById("radius")
radius.Value = "100"


'search again a larger distance
'Select Search button and activate
but.Select
but.Click
Set SearchResults = IE.document.getElementById("searchResults")

On Error Resume Next ' Defer error handling.
Do
Err.Clear
Set PageNumber = IE.document.getElementById("pageNumber")
Pages = PageNumber.Value
DoEvents
Loop While Err.Number <> 0
On Error GoTo 0


With Sheets("Dealers")
.Cells.ClearContents
RowCount = 1

For PageCount = 1 To PageNumber.Length
PageNumber.Value = Format(PageCount, "@")
PageNumber.onchange

For Each Chld In SearchResults.Children

If Chld.innertext = "" Then
Exit For
End If
Set DealerNumberObj = _
Chld.getelementsbytagname("A")
DealerNumberStr = DealerNumberObj.Item(1).pathname
dealerNumber = _
Val(Mid(DealerNumberStr, InStr(DealerNumberStr, "'") + 1))
.Cells(RowCount, "A") = dealerNumber

ColCount = 2
dealer = Chld.innertext
Do While InStr(dealer, CR) > 0
Data = Trim(Left(dealer, InStr(dealer, CR) - 1))

'remove leading CR and LF
Do While Left(Data, 1) = LF Or _
Left(Data, 1) = CR

Data = Mid(Data, 2)
Loop
dealer = Trim(Mid(dealer, InStr(dealer, CR) + 1))
If InStr(Data, "(") > 0 And _
ColCount = 4 Then

Distance = Trim(Mid(Data, InStr(Data, "(") + 1))
Distance = Trim(Left(Distance, InStr(Distance, ")") - 1))
CityState = Trim(Left(Data, InStr(Data, "(") - 1))
.Cells(RowCount, ColCount) = CityState
.Cells(RowCount, (ColCount + 1)) = Distance
ColCount = ColCount + 2
Else
.Cells(RowCount, ColCount) = Data
ColCount = ColCount + 1
End If
Loop

'remove leading CR and LF
Do While Left(dealer, 1) = LF Or _
Left(dealer, 1) = CR

dealer = Mid(dealer, 2)
Loop
.Cells(RowCount, ColCount) = dealer
RowCount = RowCount + 1
Next Chld
Next PageCount
End With
End Sub


------------------------------------------------------------------------------------------

'Run this code in a workbook with a sheet name SHEET1
Sub GenericCode()

'Enter your URL here
URL = "http://www.shockwave.com"


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


'get web page
IE.Navigate2 URL
Do While IE.readyState <> 4
DoEvents
Loop

'get TAG Item
Set A_Tags = IE.Document.getelementsbytagname("A")
'Set but = IE.document.getElementById("mainSearchButton")

RowCount = 1
With Sheets("Sheet1")
For Each itm In IE.Document.all
.Range("A" & RowCount) = itm.classname
.Range("B" & RowCount) = itm.tagname
' .Range("C" & RowCount) = Left(itm.innertext, 256)
.Range("D" & RowCount) = Left(itm.innerhtml, 256)
RowCount = RowCount + 1
Next itm
End With
End Sub
 
I have two examples of programs below.  I use a combination of techniques to
backwards engineer Web code.  I don't know Java very well and I'm not
experienced enough to be an expert but I can usally get things to work by
brute force method.

I usally got the webpage using Internet Explorer and use the menu View -
Source which will open a NotePad of the code.  I look for two things

     1) Tags, tags look like this

            start of tag is an angle bracket with the name and the close is
an angle bracket with name and backslash

     < A   ..............some text  ...........      /A >

  You can get tags in code below using this statement

      Set A_Tags = IE.Document.getelementsbytagname("A")

   2) I also look in the source code for ID's which are  : id =abc

      You can get these in code with

     'Set ABC = IE.document.getElementById("abc")

The boxes you are looking for should have usique ids which will get you the
locations to put the data.

I also dump all the items to a worksheet (sheet1) like I did in the macro
GenericCode() below.  There is a for loop with ITM in this code.  I also put
a break point in the for loop and then add ITM to the watch window to help me
debug code.  You can change the URL in this code to your website to help you
find the name of the boxes.

In the first Nissan code I added data to a text box using these two lines

     Set radius = IE.document.getElementById("radius")
     radius.Value = "100"

You need to do something similar in your code.
I hope this will get you started.
------------------------------------------------------------------------------------------------

Nissan Dealer code
Make a Worksheet called DEALERS and run this code
--------------------------------------------------------------------------------------------
Sub GetDealers()
'Dim PageNumber As Object
CR = Chr(13)
LF = Chr(10)

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

URL = "http://www.nissanusa.com/apps/dealerlocator"
Request = "?zipCode=07508&tool=Home.Locator"

'get web page
IE.Navigate2 URL & Request
Do While IE.readyState <> 4
   DoEvents
Loop

'get search button
Set but = IE.document.getElementById("mainSearchButton")
'put distance in listbox on webpage
Set radius = IE.document.getElementById("radius")
radius.Value = "100"

'search again a larger distance
'Select Search button and activate
but.Select
but.Click
Set SearchResults = IE.document.getElementById("searchResults")

On Error Resume Next    ' Defer error handling.
Do
   Err.Clear
   Set PageNumber = IE.document.getElementById("pageNumber")
   Pages = PageNumber.Value
   DoEvents
Loop While Err.Number <> 0
On Error GoTo 0

With Sheets("Dealers")
   .Cells.ClearContents
   RowCount = 1

   For PageCount = 1 To PageNumber.Length
      PageNumber.Value = Format(PageCount, "@")
      PageNumber.onchange

      For Each Chld In SearchResults.Children

         If Chld.innertext = "" Then
            Exit For
         End If
         Set DealerNumberObj = _
            Chld.getelementsbytagname("A")
         DealerNumberStr = DealerNumberObj.Item(1).pathname
         dealerNumber = _
            Val(Mid(DealerNumberStr, InStr(DealerNumberStr, "'") + 1))
         .Cells(RowCount, "A") = dealerNumber

         ColCount = 2
         dealer = Chld.innertext
         Do While InStr(dealer, CR) > 0
            Data = Trim(Left(dealer, InStr(dealer, CR) - 1))

            'remove leading CR and LF
            Do While Left(Data, 1) = LF Or _
                  Left(Data, 1) = CR

               Data = Mid(Data, 2)
            Loop
            dealer = Trim(Mid(dealer, InStr(dealer, CR) + 1))
            If InStr(Data, "(") > 0 And _
               ColCount = 4 Then

               Distance = Trim(Mid(Data, InStr(Data, "(") + 1))
               Distance = Trim(Left(Distance, InStr(Distance, ")") - 1))
               CityState = Trim(Left(Data, InStr(Data, "(") - 1))
               .Cells(RowCount, ColCount) = CityState
               .Cells(RowCount, (ColCount + 1)) = Distance
               ColCount = ColCount + 2
            Else
               .Cells(RowCount, ColCount) = Data
               ColCount = ColCount + 1
            End If
         Loop

         'remove leading CR and LF
         Do While Left(dealer, 1) = LF Or _
               Left(dealer, 1) = CR

            dealer = Mid(dealer, 2)
         Loop
         .Cells(RowCount, ColCount) = dealer
         RowCount = RowCount + 1
      Next Chld
   Next PageCount
End With
End Sub

------------------------------------------------------------------------------------------

'Run this code in a workbook with a sheet name SHEET1
Sub GenericCode()

'Enter your URL here
URL = "http://www.shockwave.com"

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

'get web page
IE.Navigate2 URL
Do While IE.readyState <> 4
   DoEvents
Loop

'get TAG Item
Set A_Tags = IE.Document.getelementsbytagname("A")
'Set but = IE.document.getElementById("mainSearchButton")

RowCount = 1
With Sheets("Sheet1")
   For Each itm In IE.Document.all
      .Range("A" & RowCount) = itm.classname
      .Range("B" & RowCount) = itm.tagname
 '     .Range("C" & RowCount) = Left(itm.innertext, 256)
      .Range("D" & RowCount) = Left(itm.innerhtml, 256)
      RowCount = RowCount + 1
   Next itm
End With
End Sub

Thank you very much for the assistance. I see how this extracts
information from the webpage. Can I load from excel to webpage?
 
Yes You can load from excel to a webpage. It is similar to putting in the
Radius of 100 miles. rather than to use a fix number of 100 the code could
be change to use data from excel

from
Set radius = IE.document.getElementById("radius")
radius.Value = "100"

to
Set radius = IE.document.getElementById("radius")
radius.Value = Sheets("Sheet1").Range("A1")

The radius would be one of the text boxes you are trying to load.
 

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

Back
Top