2012-01-22 10 views
0

私はその人の画像(その画像は公開されていて、私の目に見えるもの、つまりFacebookの現在の友人)を選択し、その人物のすべての閲覧可能な写真をその写真のタグの位置とともにダウンロードしたいと考えています。とにかくこれは公に利用できるので、問題ではないはずです。イメージ上のタグ付きの場所を抽出する方法がわかりません。閲覧可能なすべての画像+ Facebookの友人のタグ付けされた場所を掻き取ることは可能ですか?

これはoyuがFacebook APIやその他の手段で行うことができるものですか?どうしますか?

+2

「公的に利用可能」とは、「利用規約」によりデータをスクラップできることを意味するものではありません。 –

答えて

3

ユーザー情報を取得すると、あなたのアプリを認証するために、ユーザが必要となるか、人は自分のアプリを承認したユーザーと友達になる必要があるので、この情報は、グラフAPIを介して利用できなくなります。あなたはFacebookのサイトを掻き集めることができますが、これは利用規約に違反しています。掻き傷を防ぐための対策がたくさんあるので、難しいです。

1

この情報にアクセスするには、ユーザにfriends_photosの許可を求める必要があります。

明示的な許可なしにユーザーの写真をダウンロードすることは、(facebookプラットフォームポリシーに違反することに加えて)非常に厄介で邪魔なことです。もし私がこの行動を見たならば、アプリケーションは挑戦的に報告され、違反しているアプリケーションの問題がそれに応じて処理されるまで、あなたの個人アカウントが無効にされたり、

0

フルサイズの画像ではなくサムネイルのURLのリストのみを作成し、タグ付きの場所を取得しないにもかかわらず、AppleScriptのようなスクリプトを使用します。私は、彼らが常にフルサイズのバージョンにならないように、大960個のピクセルで、最大960にある画像の大きなバージョンのリストを作成するには、以下のようなスクリプトを使用し

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 

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>は、画像やユーザのためのページにリダイレクトされます。私は私の友人ではないユーザーのプロファイルを表示することができないように、自分のアカウントが時々週間制限されます、およそ千または数千ページ以上をロードした後

イメージのファイル名の2番目のアンダースコア区切りフィールドの数字は、イメージのIDです。たとえば、は12208495_10102454385528521_4749095086285673716_n.jpgです。

ユーザーIDは、a.で始まり、fb.で始まるアルバム識別子の最初の番号で始まるアルバム識別子の最後の番号です。

https://www.facebook.com/photo/download/?fbid=<fbid of photo>は、画像のフルサイズバージョンにリダイレクトするために使用されるが、それは今年の初めに動作を停止しました。

https://graph.facebook.com/<user id>/picture?width=9999はまだグラフAPIが使用できなくなったにもかかわらず働かないユーザーのフルサイズのプロフィール画像にリダイレクトされます。

関連する問題