2012-01-22 25 views
0

我想選擇一個用戶(他的圖片是公開的,可以在我的臉上看到,也就是facebook上的當前朋友),並下載該人的所有可見圖片,以及他們在該圖片中的標籤位置。無論如何,這一切都是公開的,所以它不應該是一個問題,我只是不確定如何提取圖像上的標記位置。是否有可能在Facebook上刮掉所有可見圖像+你朋友的標記位置?

這是oyu可以通過Facebook API或通過其他方式做些什麼嗎?你會怎麼做?

+2

「公開可用」並不意味着「服務條款」允許您抓取數據。 –

回答

3

由於獲取用戶信息需要用戶授權您的應用程序,或者該用戶必須與批准您的應用程序的用戶成爲朋友,因此無法通過其Graph API訪問此信息。你可以刮臉Facebook的網站,但這是違反他們的服務條款,並且很棘手,因爲他們有很多措施來防止刮蹭。

1

您需要詢問您的用戶friends_photos權限才能訪問該信息。

用戶明確授權下載用戶照片是一件令人討厭的干擾事情(除了違反facebook平臺政策外)。如果我看到了這種行爲,應用程序將被嚴格報告,並且更改是您的個人帳戶也將被停用或被阻止打開新的應用程序,直到違反應用程序問題得到相應處理。

0

我使用下面的AppleScript腳本,即使它只生成縮略圖的URL列表而不是全尺寸的圖像,並且它不會獲取標記的位置。

paragraphs of (do shell script "cat /tmp/ids_of_users") 
repeat with user in result 
    set s to "open -gagoogle\\ chrome https://www.facebook.com/profile.php?id=" & user & "\\&sk=photos_albums" 
    tell application "Google Chrome" 
     close windows 
     repeat until exists window 1 -- the open command sometimes results in an `LSOpenURLsWithRole() failed` error 
      do shell script s 
      delay 5 
     end repeat 
     repeat while loading of tabs of window 1 contains true 
      delay 1 
     end repeat 
     tell active tab of window 1 
      set albums to execute javascript "o='';a=document.querySelectorAll('.albumThumbLink');for(i=0;e=a[i];i++){o+=e.href+'\\n'};o" 
     end tell 
     if albums is not missing value and albums is not "" then 
      repeat with p in paragraphs 1 thru -2 of albums 
       do shell script "open -jgagoogle\\ chrome " & quoted form of p 
       delay 1 
      end repeat 
      repeat while loading of tabs of window 1 contains true 
       delay 1 
      end repeat 
       tell application "Google Chrome" to tell active tab of window 1 
        repeat while loading is true 
         delay 1 
        end repeat 
        set src to execute javascript "document.body.innerHTML" 
        if src contains "no photos in this album" then exit repeat 
        if src contains "you may not have permission to view this page" then return -- your account got restricted for a week by Facebook 
        set prev to 0 
        repeat 
         set y to execute javascript "document.querySelector('.fbTimelineStarGridSeparator').scrollIntoView();window.scrollY" 
         delay 1 
         if y is prev then exit repeat 
         set prev to y 
        end repeat 
        set out to execute javascript "o='';a=document.querySelectorAll('.tagWrapper i');for(i=0;e=a[i];i++)o+=e.getAttribute('style').replace(/.*?\\(/,'').replace(/\\).*/,'')+'\\n';o" 
        if out is not "" then 
         do shell script "printf %s " & quoted form of out & "|sed s/^/" & user & "\\ />>/tmp/albums" 
        end if 
       end tell 
      end if 
     end tell 
end repeat 

我使用腳本類似下面做出了較大版本的圖片,這是高達960×960像素的大名單,因此他們並不總是全尺寸版本。

paragraphs of (do shell script "cat /tmp/ids_of_images") 
repeat with photoid in result 
    tell application "Google Chrome" 
     close windows 
     repeat until exists window 1 
      do shell script "open -gagoogle\\ chrome https://www.facebook.com/" & photoid 
      delay 5 
     end repeat 
     repeat while loading of tabs of window 1 contains true 
      delay 1 
     end repeat 
     tell active tab of window 1 
      set src to execute javascript "document.querySelector('.spotlight').src" 
      if src is not missing value then 
       do shell script "echo '" & src & "'>>/tmp/bigger" 
      end if 
     end tell 
    end tell 
end repeat 

某些照片通常不會在所有照片的頁面上顯示,但會在相冊單獨瀏覽時顯示。

https://www.facebook.com/profile.php?id=<user id>&sk=photos_albums被重定向到一個用戶的相冊頁面,https://www.facebook.com/profile.php?id=<user id>&sk=photos_all被重定向到由用戶發佈的所有照片的頁面,並https://www.facebook.com/<fbid of image or user>被重定向到頁面的圖像或用戶。

加載超過一千或幾千頁後,我的帳戶有時會被限制一週,因此我無法查看不是我朋友的用戶個人資料。

圖像文件名中第二個以下劃線分隔的字段中的數字是圖像的ID,例如1010245438552852112208495_10102454385528521_4749095086285673716_n.jpg中。

用戶標識是以a.開頭的專輯標識符中的最後一個數字,以及以fb.開頭的專輯標識符中的第一個數字。

https://www.facebook.com/photo/download/?fbid=<fbid of photo>曾經被重定向到圖像的全尺寸版本,但今年早些時候停止工作。

https://graph.facebook.com/<user id>/picture?width=9999被重定向到用戶的全尺寸配置文件圖片,即使Graph API不再可用,該圖片仍然有效。

相關問題