how can download images from google image search with httputils2?
Sub JobDone (Job As HttpJob)
Dim TextReader1 As TextReader
TextReader1.Initialize(Job.GetInputStream)
Dim pattern, class As String
class = "href"
pattern = "src=\q([^q]+)\q".Replace("q", QUOTE)
Dim line As String
line = TextReader1.ReadLine
Do While line <> Null
If line.IndexOf(class) > -1 Then
Dim m As Matcher
m = Regex.Matcher(pattern, line)
Do While m.Find <> False
Dim ImageJob As HttpJob
ImageJob.Initialize("ImageJob", Me)
ImageJob.Download(m.Group(1))
Loop
End If
line = TextReader1.ReadLine
Loop
TextReader1.Close
End Sub
J.Download("https://www.google.com/search?q=car_2%20psp%20screenshot&ie=UTF-8&hl=en&tbm=isch")
B4X:Sub JobDone (Job As HttpJob) Dim TextReader1 As TextReader TextReader1.Initialize(Job.GetInputStream) Dim pattern, class As String class = "href" pattern = "src=\q([^q]+)\q".Replace("q", QUOTE) Dim line As String line = TextReader1.ReadLine Do While line <> Null If line.IndexOf(class) > -1 Then Dim m As Matcher m = Regex.Matcher(pattern, line) Do While m.Find <> False Dim ImageJob As HttpJob ImageJob.Initialize("ImageJob", Me) ImageJob.Download(m.Group(1)) Loop End If line = TextReader1.ReadLine Loop TextReader1.Close End Sub
i used this code but the link downloaded is in very low size
and smaller than google image size
how can fix that?
What do you mean not work ?this code does not work now because google changed the code page (worked good until about month ago) can anyone help?
J.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0")What do you mean not work ?
I logged m.Group(1) and got links like this
I tested UA you provided and it returned fewer results than before .J.GetRequest.SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0")
with this user agent cant get links