Retrieving images from a website using Flickr demo example

Asmoro

Active Member
Licensed User
Longtime User
Hi All,

This time I've made another test zip with the appropriate url.

Unfortunately didn't work right, but it seems doing some parsing
and then stopped afterwards.

No clue what's going on and no errors to examine.

I hope someone will find the problem.

note: change DirInternalCache to DirRootExternal
 
Last edited:

Asmoro

Active Member
Licensed User
Longtime User
Ok, I will use the new FlickrViewer for the test.

My test website url is 'http://www.blabla.com/test/'
and Flickr.com 'http://www.flickr.com/explore/interesting/7days'

So I have no subdirs in my site.I think that's the only difference
between the two.(?):sign0104:
Please correct me if I'm wrong.
 
Last edited:
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
As Erel said I made a new test with the newer version attached.

To not to get confused I will delete the first one from my earlier post.

And this is the log output I've got:

Installing file.
PackageAdded: package:anywheresoftware.b4a.samples.flickr
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Starting Job: Main page
** Service (httputilsservice) Create **
** Service (httputilsservice) Start **
done parsing main page: 16
Starting Job: Images
** Service (httputilsservice) Start **
Error. Url=bspww2_small.jpg Message=java.lang.IllegalStateException: Target host must not be null, or set in parameters.
Error. Url=photo_small.jpg Message=java.lang.IllegalStateException: Target host must not be null, or set in parameters.
Error. Url=isogrifotarga1_small.jpg Message=java.lang.IllegalStateException: Target host must not be null, or set in parameters.
Error. Url=mercedesclife_small.jpg Message=java.lang.IllegalStateException: Target host must not be null, or set in parameters.
Error. Url=morganevagt_2012_wallpaper_02_small.jpg Message=java.lang.IllegalStateException: Target host must not be null, or set in parameters.
** Service (httputilsservice) Destroy **
** Activity (main) Pause, UserClosed = false **

So I'm stuck how to change and deal with the url error.

edit: another website working with FlickrView demo in zip, available on this thread.
 
Last edited:
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
B4X:
Sub HandleMainPage
   If HttpUtils.IsSuccess(MainUrl) = False Then
      ToastMessageShow("Error downloading main page.", True)
      Return
   End If
   ResetImagesBackground
   start = DateTime.Now
   Dim TextReader1 As TextReader
   TextReader1.Initialize(HttpUtils.GetInputStream(MainUrl))
   Dim pattern, class As String
   class = "<td class=" & QUOTE & "thumbcell" & QUOTE & ">"
   pattern = "img src=\q([^q]+)\q".Replace("q", QUOTE)
   Dim links As List
   links.Initialize
   Dim line As String
   line = TextReader1.ReadLine
   Do While line <> Null
      If line.IndexOf(class) > -1 Then
         Dim link As String
         Dim m As Matcher
         m = Regex.Matcher(pattern, line)
         If m.Find Then
            links.Add("http://www.testtest.bugs3.com/test/" & m.Group(1)) 'add the image link
         End If
      End If
      line = TextReader1.ReadLine
   Loop
   TextReader1.Close
   Log("done parsing main page: " & (DateTime.Now - start))
   HttpUtils.CallbackUrlDoneSub = "ImageUrlDone"
   HttpUtils.DownloadList("Images", links)
   ImageIndex = 0
   btnConnect.Enabled = False
   ProgressDialogHide
End Sub
 
Upvote 0

Asmoro

Active Member
Licensed User
Longtime User
Thanks a million vb1992,

It's working great :sign0188: and time to move on with developing.

In case someone wants to use it whatever the reason is,
I'll put a zip underneath to explore.
 

Attachments

  • another website using FlickrView demo.zip
    10.5 KB · Views: 366
Upvote 0
Top