Extract image form html

Discussion in 'Rebol' started by MaxV, Mar 8, 2011.

  1. MaxV

    MaxV Member

  2. Graham

    Graham Developer Staff Member

    I have a GUI based script that does that .. it's on my rebsite.
  3. MaxV

    MaxV Member

    Un compkarori rebsite I found imagegrabber, but I obtain:

    ** Script Error: imagelist has no value
    ** Where: grabimages
    ** Near: clear imagelist
    if not equal?
    >>
  4. Graham

    Graham Developer Staff Member

    It's a pretty old script .. and presumably there has been a change in the VID syntax.
  5. swhite

    swhite Member

    Is the IMG tag the only one with the SRC option? Could you load the whole web page as a string and set up a loop to "find" the string "src=", and then pick off characters to the ">"? Not that I personally know how to do that...
  6. Graham

    Graham Developer Staff Member

  7. Graham

    Graham Developer Staff Member

  8. Graham

    Graham Developer Staff Member

    I've updated this script written in 2002 to refer to the correct file now!
  9. MaxV

    MaxV Member

    OK, image fecther works great! But I'm interested in parsing to find string matching something like:
    Code:
    src="http*.jpg"
    
  10. Graham

    Graham Developer Staff Member

    Doesn't webimages.r do that sort of parsing?
  11. MaxV

    MaxV Member

    webimager.r works with correct html pages. Nowdays a lot of sites use a strange mix of php + html + javascript, so a image link is something like:
    Code:
    <script>big_pipe.onPageletArrive({"phase":1,"id":"pagelet_profile_photo","bootloadable":{"profile-boxes-edit":["nzRk6","+ULAZ","nAGI9","sW6GL","1iIBU","FJ3LF","s5vTT","Xi9ib"],"flyout-menu":["nzRk6","+ULAZ","1iIBU","sW6GL","FJ3LF"]},"css":["nAGI9","s5vTT"],"js":["nzRk6","+ULAZ"],"resource_map":{"s5vTT":{"type":"css","src":"http://static.ak.fbcdn.net/rsrc.php/v1/yE/r/zTXUbxO6Js_.css"},"Xi9ib":{"type":"js","src":"http://static.ak.fbcdn.net/rsrc.php/v1/yF/p/r/2sXANa0-shd.js"}},"onload":["window.__UIControllerRegistry["c4d76202aa9b9b4525988444"] = new UIPagelet("c4d76202aa9b9b4525988444", "/pagelet/profile/profile_photo.php", {"profile_id":99459740077,"sk":"wall","story_fbid":null}, {});; ;"],"content":{"pagelet_profile_photo":"u003cdiv id="c4d76202aa9b9b4525988444">u003cdiv id="profileimage" class="profileimage can_edit" onmouseover="CSS.removeClass($("edit_profilepicture"), "hidden_elem")" onmouseout="CSS.addClass($("edit_profilepicture"), "hidden_elem")">u003cspan>u003cimg class="logo img" src="http://profile.ak.fbcdn.net/hprofile-ak-snc4/41779_99459740077_2290_n.jpg" alt="Rebol" id="profile_pic" />u003c/span>u003ca class="hidden_elem" href="#" onclick="Bootloader.loadComponents(["profile-boxes-edit","flyout-menu"], function() {  var flyout = profilePictureEditorCreateFlyout();});" id="edit_profilepicture" title="Cambia immagine">Cambia immagineu003cspan id="edit_profilepicture_icon">u003c/span>u003c/a>u003cdiv class="flyout_menu hidden_elem flyout_menu_18 link_menu" id="profile_picture_flyout">u003cdiv class="flyout_menu_header_shadow">u003cdiv class="flyout_menu_header clearfix">u003cdiv class="flyout_menu_mask">u003c/div>u003cdiv class="flyout_menu_title">Modifica la tua immagine del profilou003c/div>u003c/div>u003c/div>u003cdiv class="flyout_menu_content_shadow">u003cdiv class="menu_content">u003cdiv class="wrapper">u003ca rel="dialog" id="profile_picture_upload" href="/ajax/profile/picture/upload.php?id=99459740077" class="icon_link" title="Carica una nuova immagine del profilo">Carica un'immagineu003c/a>u003ca rel="dialog" id="profile_picture_camera" href="/camera/dialog.php?id=99459740077&amp;inline=1" class="icon_link" title="Usa la webcam per scattare una foto per il tuo profilo">Scatta una fotou003c/a>u003c/div>u003c/div>u003c/div>u003c/div>u003ciframe class="fbUploadIframe" name="profile_edit_pic_iframe" src="http://static.ak.facebook.com/common/redirectiframe.html" style="width:1px;height:1px;position:absolute;top:-10000px">u003c/iframe>u003c/div>u003c/div>"}});</script>
    
    in this mess there is:
    Code:
    src="http://profile.ak.fbcdn.net/hprofile-ak-snc4/41779_99459740077_2290_n.jpg"
    
    How to find that string? :confused:
  12. MaxV

    MaxV Member

    I resolved this way:
    copy page to openoffice (open office purge all code in simple html!!!!)
    openoffice convert to html
    upload to internet html page
    use your image grabber
    WOW
    I'll publish soon something very interesting....!!!!
  13. Graham

    Graham Developer Staff Member

    Can't you just parse the source for src="...*.png" ?
  14. MaxV

    MaxV Member

    It's not so easy, for me. If I have many src=*.jpg , parse take the first src and the last .jpg; pratically take all the source.
  15. notchent

    notchent Member

    rebol []
    code: read to-url request-text/title "URL:"
    strings: copy []
    parse code [any [thru {src="} copy a-string to {.jpg"} (append strings a-string)] to end]
    editor code

Share This Page