html - How to get META keywords content with VBA from source code in an EXCEL file -


i have download source code of several hundred websites excel file (for example cells(1, 1) in worksheets 1) , extract content of of meta tag keywords in let's cells(1, 2).

for downloading use following code in vba:

dim htm object set htm = createobject("htmlfile") url = "https://www.insolvenzbekanntmachungen.de/cgi-bin/bl_aufruf.pl?phpsessid=8ecbeb942c887974468b9010531fc7ab&datei=gerichte/nw/agkoeln/16/0071_in00181_16/2016_06_10__11_53_26_anordnung_sicherungsmassnahmen.htm" createobject("msxml2.xmlhttp")     .open "get", url, false     .send     htm.body.innerhtml = .responsetext     cells(1, 1) = .responsetext end 

i've found following code on website but, unfortunately, i'm unable adapt solve problem:

sub getdata() dim ie new internetexplorer dim str string dim wk worksheet dim webpage new htmldocument dim item htmlhtmlelement  set wk = worksheets(1) str = "https://www.insolvenzbekanntmachungen.de/cgi-bin/bl_aufruf.pl?phpsessid=8ecbeb942c887974468b9010531fc7ab&datei=gerichte/nw/agkoeln/16/0071_in00181_16/2016_06_10__11_53_26_anordnung_sicherungsmassnahmen.htm" ie.visible = true  ie.navigate str      doevents loop until ie.readystate = readystate_complete   'find proper meta element -------------- const meta_tag string = "meta" const meta_name string = "keywords" dim doc htmldocument dim metaelements object dim element object dim kwd string   set doc = ie.document set metaelements = doc.all.tags(meta_tag)  each element in metaelements     if element.name = meta_name         kwd = element.content     end if next  msgbox kwd 

end sub

i think have modify line, don't know how:

set doc = ie.document 

can please me out?

embed webrowsercontrol excel spreadsheet or userform
how add webrowser excel
set references html object library
how add vba references – internet controls, html object library

grab greg truby's code post webbroswer control

you'll have access document object model (dom). expose of htmlelements properties , event's

option explicit  private withevents htmdocument htmldocument private withevents mybutton htmlbuttonelement  private function mybutton_onclick() boolean     msgbox "sombody click mybutton on webbrowser1" end function  private sub webbrowser1_navigatecomplete2(byval pdisp object, url variant)     dim atags hyperlinks      until .readystate = readystate_complete         doevents     loop      set mybutton = htmdocument.getelementbyid("mybuttonid")     set htmdocument = webbrowser1.document     set atags = htmdocument.getelementsbytagname("a") end sub 

google web api, hta, (mdn){https://developer.mozilla.org/en-us/docs/web/api} , if stuck try refactor javascript code vbscript. it's


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -