Tag:vba Web page data
Not implemented timed refresh sub fetch stock price () on error resume nextset regx = createobject (" VBScript.RegExp ") ' regx. global = trueregx.pattern = "\[" "(. *)" "," "(. *)" ", (\d+), (. *), (. *), (\d{8}). *\]" "arr_ Stock = range (Cells (2, 1), cells (Cells (rows.count, 1). End (Xlup). row, 1) ' stock code array string_stock = join (Application.transpose (Arr_stock), ",") ' The stock code array is divided into strings https = "http://q.jrjimg.cn/?q=cn|s&i=" https = https & string _stock & "&c=code,name,np,pl,time,stp&o=pl,d&n=realhqxny_concept_9000&_= 1507340273905 "Set ie = createobject (" Internetexplorer.application ") ie.navigate httpsDo Until ie.readystate = 4 DoEventsLoopWith ie.document string_body = .body.innerText ' returned code Set Mh = regx. Execute (string_body) ' Apply regular for each m in mh i = i + 1 cells (i + 1, 2) = M.submatches (1) ' Company name cells (i + 1, 3) = m.submatches (3) ' Price cells (i + 1, 4) = m.submatches (4) ' Change cells (i + 1,  5) = m.submatches (5) ' Date next ie. Quitend withset ie = nothingset regx = nothingend sub
VBA query price based on stock code