Tuesday 15 January 2013

excel - Get data out of a webpage with VBA -



excel - Get data out of a webpage with VBA -

i'm trying info out of webpage:

http://www.vodafone.de/privat/handys-tablets-tarife/smartphone-tarife.html

i want have whole table on right site every smartphone , every contract type.

one time payment setting up: anschlusspreis

one time payment phone: smartphone

total amount: gesamt

monthly payment contract: basispreis

monthly payment mobile phone: smartphone-zuzahlung

this stored in javascript part huge amout of letters.

i´m trying utilize excel vba:

sub button1_click() 'on error goto errorhandler dim ie object, doc object, rng object, ticker string, quote string set ie = createobject("internetexplorer.application") = 1 'application.statusbar = "your request loading. please wait..." ie.navigate "http://www.vodafone.de/privat/handys-tablets-tarife/smartphone-tarife.html" 'ie.navigate ticker doevents loop until ie.readystate = readystate_complete set doc = ie.document quote = doc.getelementsbyid("connectionfeeval").innertext cells(3, 3).value = quote msgbox ("done") 'errorhandler: 'if err = 91 msgbox "error message" ie.application.quit end sub

but continuously looping @ "doevents".

does have thought why , how can solve , maybe thought how info out of page.

thank in advance.

instead of using ie automation can utilize http request object:

dim orequest object set orequest = createobject("winhttp.winhttprequest.5.1") orequest.open "get", "http://www.vodafone.de/privat/handys-tablets-tarife/smartphone-tarife.html" orequest.send msgbox orequest.responsetext

it's faster , doesn't need many ressources solution ie

if behind proxy server can utilize this:

const httprequest_proxysetting_proxy = 2 dim orequest object set orequest = createobject("winhttp.winhttprequest.5.1") orequest.setproxy httprequest_proxysetting_proxy, "http://proxy.intern:8080" orequest.open "get", "http://www.vodafone.de/privat/handys-tablets-tarife/smartphone-tarife.html" orequest.send msgbox orequest.responsetext

of course of study have adjust proxy values.

as interessted in high german page here short explanation in high german language: http://cboden.de/softwareentwicklung/vba/tipps-tricks/27-webseite-per-vba-ansprechen there explained how pass values of form webserver might helpfull you.

excel vba excel-vba

No comments:

Post a Comment