色々やってます

スクレイピングにはまっていまぁ~す。時々、流木、ビーチグラス情報。夕食はほぼ毎日。

selectタグのスクレイピング

2020-02-21 11:41:21 | VBA

<select>タグの<option>タグで Selectedされているtextをスクレイピングするコード

【VBA】

For Each objINPUT In ie.document.getElementsByName("tDFK1CmbBox")(0).all '''''''''スクレイピング

     If objINPUT.tagname = "OPTION" Then

        If objINPUT.Selected Then

            keyword.Range("B4") = objINPUT.outerText '''''スクレイピング

            Exit For

         End If

      End If

Next

【HTML例】

'<select name="tDFK1CmbBox" id="ID_tDFK1CmbBox">

'<option value="" selected=""></option>

'<option value="01">北海道</option>

省略


inputをスクレイピング

2020-02-21 11:29:18 | VBA

<input>タグのcheckedをスクレイピングするコード 以下のようなHTMLでcheckedされたtext(以下の例では一般求人)

【VBA】

For Each objINPUT In ie.document.all.tags("label")

     If InStr(objINPUT.outerHTML, "ID_LkjKbnRadioBtn1") > 0 Then

       If InStr(objINPUT.outerHTML, "checked") > 0 Then                  

            keyword.Range("B2") = objINPUT.outerText '''''スクレイピング" 

       End If 

    End of

Next

【HTML例】ハローワークHPから '求人区分 '<label id="ID_LkjKbnRadioBtn1" for="ID_kjKbnRadioBtn1"><input name="kjKbnRadioBtn" id="ID_kjKbnRadioBtn1" type="radio" checked="" value="1">一般求人</label> '<label id="ID_LippanCKBox1" for="ID_ippanCKBox1"><input name="ippanCKBox" id="ID_ippanCKBox1" type="checkbox" value="1">フルタイム</label> '<label id="ID_LippanCKBox2" for="ID_ippanCKBox2"><input name="ippanCKBox" id="ID_ippanCKBox2" type="checkbox" value="2">パート</label> '<label id="ID_LkjKbnRadioBtn2" for="ID_kjKbnRadioBtn2"><input name="kjKbnRadioBtn" id="ID_kjKbnRadioBtn2" type="radio" value="2">新卒・既卒求人</label> '<label id="ID_LkjKbnRadioBtn3" for="ID_kjKbnRadioBtn3"><input name="kjKbnRadioBtn" id="ID_kjKbnRadioBtn3" type="radio" value="3">季節求人</label> '<label id="ID_LkjKbnRadioBtn4" for="ID_kjKbnRadioBtn4"><input name="kjKbnRadioBtn" id="ID_kjKbnRadioBtn4" type="radio" value="4">出稼ぎ求人</label> '<label id="ID_LkjKbnRadioBtn5" for="ID_kjKbnRadioBtn5"><input name="kjKbnRadioBtn" id="ID_kjKbnRadioBtn5" type="radio" value="5">障害のある方のための求人</label> '<label id="ID_LsGSYACKBox1" for="ID_sGSYACKBox1"><input name="sGSYACKBox" disabled="" id="ID_sGSYACKBox1" type="checkbox" value="1">フルタイム</label> '<label id="ID_LsGSYACKBox2" for="ID_sGSYACKBox2"><input name="sGSYACKBox" disabled="" id="ID_sGSYACKBox2" type="checkbox" value="2">パート</label>