dcsimg
Results 1 to 6 of 6

Thread: iterate all row in html table

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,908

    iterate all row in html table

    part of my code:
    Code:
                 Set ObjElement = IE.document.all().tags("table").Item(2)
                PAESE = UCase(ObjElement.Rows(1).Cells(1).innerText)
                CAP = UCase(ObjElement.Rows(1).Cells(2).innerText)
                NAZIONE = UCase(ObjElement.Rows(1).Cells(3).innerText)
                REGIONE = UCase(ObjElement.Rows(1).Cells(4).innerText)
                CITTA = UCase(ObjElement.Rows(1).Cells(5).innerText)
                LATD = Trim(Split(ObjElement.Rows(2).Cells(1).innerText, "/")(0))
                LNGT = Trim(Split(ObjElement.Rows(2).Cells(1).innerText, "/")(1))
    this code get only the first row in table...

    but in this case:

    http://www.geonames.org/postalcode-s...oma&country=IT

    i need to get all rows in table???? peraphs with a for next...

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,507

    Re: iterate all row in html table

    try using the length of rows to loop through all
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,908

    Re: iterate all row in html table

    Quote Originally Posted by westconn1 View Post
    try using the length of rows to loop through all
    ????

    no experience, on Html

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    24,507

    Re: iterate all row in html table

    how about like
    Code:
    for each objrw in ObjElement.getelementsbytagname("tr")
    of course your variables would need to be arrays or collections or somesuch, possibly a udt, containing all the properties
    if arrays you would need to make sure that the array is big enough for the possible number of rows, with a collection, you would nee a unique key for each and just add items
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Italy-Napoli
    Posts
    1,908

    Re: iterate all row in html table

    Quote Originally Posted by westconn1 View Post
    try using the length of rows to loop through all
    ????

    no experience, on Html

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,535

    Re: iterate all row in html table

    Web scraping is never a correct practice. Many sites explicitly prohibit it and most dislike it because it puts expensive burdens on servers and eats unnecessary bandwidth. Sites or not required to post notices that they prohibit the practice.

    Many have had to resort to detecting patterns of use and banning access. If your program is detected as a vampire they may ban access by your entire IP subnet so you can cause yourself real grief if you've been scarping somebody like Google.

    Just don't do it.

    That site has options for automated use of their data. See http://www.geonames.org/export/


    This is not only fairer to them, it is easier to process and far less subject to page layout changes that will break your scraping logic.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width