【VBScript】Webサイトのh1,keyword,description,titleタグの情報を取得
スポンサーリンク
ちょっくら知り合いにWebマーケ担当してってボランティアで頼まれたので、まずSEO対策から!ということで現状のサイト情報を調べるためのスクリプトを作った。forでurl指定して回せば、簡単に一覧が取得できるでしょう。Pythonでやってみたかったけど、モジュールのインストールがうまく行かず。。。VBScriptでがまんした。(UTF-8のページだと一部文字化けします)
ReqPath = "WebサイトURL" Set objShell = WScript.CreateObject("WScript.Shell") Set objXmlHttp = WScript.CreateObject("MSXML2.XmlHttp") objXmlHttp.Open "GET", ReqPath, False objXmlHttp.Send intStatus = objXmlHttp.status strHtml = objXmlHttp.responseText 'get <title></title> strSearch_title_s = "<title>" strSearch_title_e = "</title>" wLen_s = Len(strSearch_title_s) wLen_e = Len(strSearch_title_e) pos_title_s = InStr(strHtml, strSearch_title_s) + wLen_s pos_title_e = InStr(strHtml, strSearch_title_e) str_title = Mid(strHtml, pos_title_s, pos_title_e - pos_title_s) 'get <h1></h1> strSearch_h1_s = "<h1>" strSearch_h1_e = "</h1>" wLen_s = Len(strSearch_h1_s) wLen_e = Len(strSearch_h1_e) pos_h1_s = InStr(strHtml, strSearch_h1_s) + wLen_s pos_h1_e = InStr(strHtml, strSearch_h1_e) str_h1 = Mid(strHtml, pos_h1_s, pos_h1_e - pos_h1_s) 'get <meta name="keywords" content=""> strSearch_keyword_s = "<meta name=""keywords"" content=""" strSearch_keyword_e = """>" wLen_s = Len(strSearch_keyword_s) wLen_e = Len(strSearch_keyword_e) pos_keyword_s = InStr(strHtml, strSearch_keyword_s) + wLen_s pos_keyword_e = InStr(pos_keyword_s,strHtml, strSearch_keyword_e) str_keyword = Mid(strHtml, pos_keyword_s, pos_keyword_e - pos_keyword_s) 'get <meta name="descrptin" content=""> strSearch_description_s = "<meta name=""description"" content=""" strSearch_description_e = """>" wLen_s = Len(strSearch_description_s) wLen_e = Len(strSearch_description_e) pos_description_s = InStr(strHtml, strSearch_description_s) + wLen_s pos_description_e = InStr(pos_description_s,strHtml, strSearch_description_e) str_description = Mid(strHtml, pos_description_s, pos_description_e - pos_description_s) msgbox str_title msgbox str_h1 msgbox str_keyword msgbox str_description Set objXmlHttp = Nothing