Ok so here is the code which opens a browser, search word from cell and gives the resault of searching in google images.
What I want it to do:
It should get the title of the website (search images resault page)
and put it into the cell (any)
And here is the code which is based on another command:
This code worked on websites like google.com and it gave the title="google"
But with the site like the one which is written upper it gives "Forbidden 403!"
Can someone modify first code to do what the second code ? (But with IE.navigate etc it should work)
What I want it to do:
It should get the title of the website (search images resault page)
and put it into the cell (any)
Code:
ub DZIALAJCEZIEALBOJUZCHROME2()
Dim IE As Object
Dim i As Long
Dim title As String
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True 'Just for our test
.navigate "https://www.google.com/search?site=imghp&tbm=isch&source=hp&biw=1920&bih=858&q=" & Worksheets("Arkusz6").Range("A2").Text & Worksheets("Arkusz6").Range("Z2").Text
Do While .ReadyState <> 4: DoEvents: Loop
Do While .Busy: DoEvents: Loop
With .Document
For i = 0 To .Links.Length - 1
If InStrB(1, .Links(i).innerText, "A80147200") Then
IE.navigate .Links(i).href
Do While IE.ReadyState <> 4: DoEvents: Loop
Do While IE.Busy: DoEvents: Loop
MsgBox .URL
Exit For
End If
Next i
End With
End With
Set IE = Nothing
End Sub
And here is the code which is based on another command:
Code:
Sub Znajdz_grafike()
Dim s As String
Dim title As String
Dim objHttp As Object
Set objHttp = CreateObject("MSXML2.ServerXMLHTTP")
If Right(s, 3) <> "htm" And Right(s, 4) <> "html" Then
If Right(s, 1) <> "/" Then s = s & "/"
End If
objHttp.Open "GET", "http://www.google.com/search?site=imghp&tbm=isch&source=hp&biw=1920&bih=858&q=" & Worksheets("Arkusz6").Range("A2").Text & Worksheets("Arkusz6").Range("Z2").Text, False
objHttp.send ""
title = objHttp.responseText
If InStr(1, UCase(title), "<TITLE>") Then
title = Mid(title, InStr(1, UCase(title), "<TITLE>") + Len("<TITLE>"))
title = Mid(title, 1, InStr(1, UCase(title), "</TITLE>") - 1)
Else
title = ""
End If
Range("A5").Value = title
End Sub[/B]
This code worked on websites like google.com and it gave the title="google"
But with the site like the one which is written upper it gives "Forbidden 403!"
Can someone modify first code to do what the second code ? (But with IE.navigate etc it should work)