vba - Generate Webpage Titles from List of URLs in Excel -
i have column in excel of website urls , automatically retrieve webpage titles each of urls , place them in second corresponding column.
i don't have experience vba, use vba this. can please list steps one-by-one done? code paste , where? how point code right column pick urls , how tell populate results? how run code?
i think popular problem many don't uses existing documentation on how address because have same issue me -- don't know how load , run script.
any appreciated! please detailed possible.
adjust range "a1:a10" match data....
sub gettitles() dim c range, url string each c in range("a1:a10").cells url = trim(c.value) if lcase(url) "http://*" c.offset(0, 1).value = gettitle(url) end if next c end sub function gettitle(surl string) dim title string, res string, pos1, pos2 dim objhttp object set objhttp = createobject("msxml2.serverxmlhttp") objhttp.open "get", surl, false objhttp.send "" res = objhttp.responsetext pos1 = instr(1, ucase(res), "<title>") pos2 = instr(1, ucase(res), "</title>") title = "<not found>" if pos1 > 0 , pos2 > 0 pos1 = pos1 + len("<title>") title = mid(res, pos1, pos2 - pos1) end if gettitle = title end function
Comments
Post a Comment