こんにちは
Sub test()
'参照設定 Microsoft HTML Object Library
Dim objIE As Object
Dim Button As Object
Dim i As Long
Dim j As Long
Dim htmlDoc As HTMLDocument
Dim el As IHTMLElement
Set objIE = CreateObject("InternetExplorer.Application")
objIE.Visible = True
For i = 1 To 100
If Cells(i, 1) <> "" Then
j = 2
objIE.navigate "http://mnrate.com/search?i=All&kwd=" & Cells(i, 1)
While objIE.readyState <> 4 Or objIE.Busy = True
DoEvents
Wend
Set htmlDoc = objIE.document
For Each el In htmlDoc.Links
If InStr(1, el, "http://mnrate.com/item/aid/") > 0 Then
If Rows(i).Find(el, Cells(i, 2), xlValues, xlWhole) Is Nothing Then
j = j + 1
Cells(i, j) = el
End If
End If
Next
If j = 3 Then
Cells(i, j) = objIE.locationurl
End If
End If
Next
objIE.Quit
Set objIE = Nothing
End Sub
こんな感じで出来ますか?
こういうやり方もある
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal ms As Long)
Sub test()
'参照設定 Microsoft HTML Object Library
'参照設定 Microsoft InternetExplorer
Dim objIE As InternetExplorer
Dim htmlDoc As HTMLDocument
Dim i As Long
Set objIE = New InternetExplorer
objIE.Visible = True
objIE.navigate "http://mnrate.com/"
While objIE.readyState <> 4 Or objIE.Busy = True
Sleep 1000
Wend
Set htmlDoc = objIE.document
For i = 1 To 100
If Cells(i, 1) <> "" Then
htmlDoc.forms(0).elements("_item_search_inp").Value = Cells(i, 1).Value
htmlDoc.forms(0).elements("_graph_search_btn").Click
Sleep 3000
While objIE.readyState <> 4 Or objIE.Busy = True
Sleep 1000
Wend
If htmlDoc.forms.Length > 1 Then
Cells(i, 2).Value = htmlDoc.forms(1).elements("asin").Value
Cells(i, 3).Value = objIE.locationurl
Else
Cells(i, 4).Value = "Hitしませんでした"
End If
End If
Next
objIE.Quit
Set objIE = Nothing
End Sub
お礼
返信ありがとうございました。 さすがカテゴリーマスターですね。 とても勉強になりました。 一つずつ理解していくのは、難しいけど頑張っていきます。 感謝してます。