excel - Obtain web data after logging into website -
i'm trying data website requires log in user , password. i've followed this tutorial , managed log website, reason it's not getting table.
here's code:
sub gettable() dim ieapp internetexplorer dim iedoc object dim ietable object dim clip dataobject 'create new instance of ie set ieapp = new internetexplorer 'you don’t need this, it’s debugging ieapp.visible = true 'assume we’re not logged in , go directly login page ieapp.navigate "https://accounts.google.com/servicelogin" while ieapp.busy: doevents: loop until ieapp.readystate = readystate_complete: doevents: loop set iedoc = ieapp.document 'fill in login form – iedoc.forms(0) .email.value = "email@email.com" .passwd.value = "password" .submit end while ieapp.busy: doevents: loop until ieapp.readystate = readystate_complete: doevents: loop 'now we’re in, go page want ieapp.navigate "my-website.com" while ieapp.busy: doevents: loop until ieapp.readystate = readystate_complete: doevents: loop 'get table based on table's id set iedoc = ieapp.document = 0 (iedoc.all.length - 1) 'only @ tables if typename(iedoc.all(i)) = “htmltable” set ietable = iedoc.all(i) 'i want check 3rd row (.rows(2)) , error if there 'are less 3 rows. if ietable.rows.length > 2 'here’s text in first cell of third row tells me 'i have right table if ietable.rows(0).cells(0).innertext = "text" 'copy tables html clipboard , paste teh sheet if not ietable nothing set clip = new dataobject clip.settext "<html>" & ietable.outerhtml & "</html>" clip.putinclipboard sheet1.select sheet1.range("a1").select sheet1.pastespecial "unicode text" end if end if end if end if next 'close 'er ieapp.quit set ieapp = nothing end sub
Comments
Post a Comment