Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https://gnmerritt.net/deletefacebook/2018/04/03/fb-photos-of-me/ #1

Open
utterances-bot opened this issue Jun 29, 2018 · 33 comments
Open

Comments

@utterances-bot
Copy link

Downloading Photos of You from Facebook

https://gnmerritt.net/deletefacebook/2018/04/03/fb-photos-of-me/

Copy link

Hey Nathan - thanks so much for putting together this useful post. I've been looking for a good way to download photos others have tagged me in, so I can wash my hands of FB. I need some help though; I managed to succesfully execute all the steps but I'm confused about the shell command bit.

After I've created and saved the text file containing the javascript, what do I do? Where am I meant to type the command, and in what format exactly do I insert the file path into the command? How do I choose where I would like the files to be saved? Sorry, I'm a real novice with a lot of this stuff. I'd appreciate any pointers. Thanks!

Copy link

ftaneski commented Jul 1, 2018

Hi Nathan, thanks for the instructions. I created the text file with the output from the javascript snippet and called it myfbphotos.txt and saved it on my Desktop

Then I opened my terminal (I'm on a mac) and ran the following command:

cat Desktop/myfbphotos.txt | sed -E 's/VM[[:digit:]]+:[[:digit:]]+ //' | xargs -n1 -P4 wget

But when I run the command I get "xargs: wget: No such file or directory". Am I going about this the wrong way?

Kind regards,
Filip

Copy link
Owner

@ftaneski You'll need to make sure the wget program is installed on your mac. Step one is to install homebrew, step two is to run brew install wget.

@thehappycollector You'll want to be running the commands in the Terminal application (apps -> utilities -> terminal). Let's say that you saved the file on your desktop into a file named fb-photos.txt. You'd enter the following commands into a freshly opened terminal in order to complete the download (hit enter after every line, don't worry about pasting stuff after the #). Just start typing the name of your file in the terminal and hit tab a couple times - it will auto-complete the full filename for you.

cd ~/Desktop        # navigate the terminal to the right folder. cd = 'change directory'
ls                     # ls = 'list files' this will show you a list of all the files in your Desktop folder, make sure you see your photos file
mkdir fb_photos     # make a directory for your photos
cd fb_photos          # navigate the terminal there
cat ../fb-photos.txt | sed -E 's/VM[[:digit:]]+:[[:digit:]]+ //' | xargs -n1 -P4 wget
open .                # opens up the folder you created in Finder

Copy link

Novack commented Jul 24, 2018

Nicely done, great info. Thanks for sharing!

One comment: the procedure to download all photos you’re tagged in, results in downloading pictures smaller than the actual photo resolution that facebook has. Its not a thumbnail, but neither is the actual picture. Will look into options to get to the final photos...

This part of the photos you're tagged in, is the most difficult to solve in general when trying to retrieve the data out of fb.

Copy link

Novack commented Jul 25, 2018

Sorry just now I found yuor final TODO note regarding the same thing I noted. I will check on it too.

@gnmerritt
Copy link
Owner

Thanks! Let me know if you come up with a reliable way to find higher-res versions of photos given the media id or anything else we can scrape off the page. I tinkered around with it for a while and didn't make any progress...

Copy link

Novack commented Jul 25, 2018

Got it.

To get the full size photo, given an fbid, we can use the following url:
https://m.facebook.com/photo/view_full_size/?fbid=

Now, following your snippet on the console approach, we can collect all fbids using:
for (link of document.getElementsByTagName('a')) { if (!link.href.includes("?fbid=")) continue; console.log(new URL(link.href).searchParams.get("fbid")); }

Or even better, we can get the list ready to paste into a file with:
for (link of document.getElementsByTagName('a')) { if (!link.href.includes("?fbid=")) continue; console.log("https://m.facebook.com/photo/view_full_size/?fbid=" + new URL(link.href).searchParams.get("fbid")); }

Thanks!

Copy link

Novack commented Jul 25, 2018

Now to a more mundane challenge: what to use to download that image list, which requires fb login and redirection following...

Copy link

Hey I made an account to comment this. I'm hoping someone can help me out. I found my facebook id, then I loaded up all my tagged photos using the link provided. Now I'm at this part:

"Next, pick out all the images on the page with this javascript snippet:
for (img of document.getElementsByTagName('img')) { if (!img.alt) continue; console.log(img."

I have no idea what this means whatsoever. Like, wouldn't know where to start. Can someone help me? Really want to delete facebook. I'm using a mac if that matters.

In addition to this, I noticed in the comments there's a solution to the problem in the original post where the photos don't download at the full resolution. If someone could help me with this too it would be so appreciated!

Copy link

catmc37 commented Sep 9, 2018

Hi, thanks so much for publishing this. Really helpful stuff.

@gnmerritt I'm getting stuck at a similar point to others. I've created the code file, but don't know how to apply the final bit of code to download the pictures. As a Windows user, do I use 'Command Prompt'? Do I need to download homebrew and wget too? When I open 'Command Prompt' I have an intro of 'C:\User\Hp840>' - can I type commands directly after this? I'm a total novice with coding, so if anyone could paste a screenshot of exactly what to type I'd be really grateful. I was pasting this into command prompt and getting no where: cat <C:\Users\Hp840\Documents\fb-pic-code.txt> | sed -E 's/VM[[:digit:]]+:[[:digit:]]+ //' | xargs -n1 -P4 wget

@patrickconneely - you can open a javascript console on a page by pressing 'ctrl' + 'shift' + 'j'. This is where you paste in the code to get the information to paste into a text file. Does that work? I don't really know what I'm talking about either!

Copy link

ghost commented Sep 9, 2018

Hey everyone. So I got all the way to the end, all the pictures seemed to download, but where do they download to?

Thanks!

Copy link

ghost commented Sep 11, 2018

Anyone?

Copy link

Ngalano commented Sep 23, 2018

Thanks so much for this. When I attempt using a shell in MacOS I get a 403: forbidden error. I've tried all the "user-agent" tricks and none work... any suggestions?

Copy link

I keep getting errors 403 forbidden errors. Anyone else getting that? How do I get around that?

Copy link
Owner

Sorry everybody, I have long since deleted my account so I'm not able to verify whether or not this still works. If you drop me a line (nathan@ this domain) with an updated solution I'm happy to post it & credit you

Copy link

@Novack
To get the full size photo, given an fbid, we can use the following url:
https://m.facebook.com/photo/view_full_size/?fbid=

Now, following your snippet on the console approach, we can collect all fbids using:
for (link of document.getElementsByTagName('a')) { if (!link.href.includes("?fbid=")) continue; console.log(new URL(link.href).searchParams.get("fbid")); }

Or even better, we can get the list ready to paste into a file with:
for (link of document.getElementsByTagName('a')) { if (!link.href.includes("?fbid=")) continue; console.log("https://m.facebook.com/photo/view_full_size/?fbid=" + new URL(link.href).searchParams.get("fbid")); }

could you please explain this further? --
I've tried the URL with the fbid for a single photo and FB tells me I don't have access. Really desperate to get the full size photos off FB! Thanks

Copy link

@SirRodneySmodge I think I've figured something out to get the full-size photos :)

on this same page, click on the first picture to open the "spotlight":
https://www.facebook.com/search/YOUR_ID_NUM_HERE/photos-of/intersect

copy/paste this into your console and let it run free!

let interval;
interval = setInterval(() => {
    console.log(document.querySelector('._2-sx').firstElementChild.getAttribute('src'));
    document.querySelector('a.next').click();
}, 1000);

it's a bit finicky at times (i.e., got stuck on a photo and wouldn't advance to the next one) at which point you can first stop the script from running using this:

clearInterval(interval);

then close out of the spotlight, open it up again at the photo it got stuck on, and start the script again from the interval = ... line.

I also noticed the photos were downloading with the query params, so I ran this in my terminal as a final step to get OS X to recognize them as image files:

rename 's/\?_nc_cat.*//g' *

note: had to run brew install rename first

let me know if any of that doesn't make sense! unfortunately Facebook never had the highest resolution for images, but I can confirm from one photo at least that using "Download" from the Facebook UI yielded the same photo as the script above.

@SirRodneySmodge
Copy link

SirRodneySmodge commented Dec 29, 2018 via email

Copy link

@caseklim +1 on the thanks - that worked great!

Copy link

caseklim commented Jan 2, 2019

@SirRodneySmodge @mikeclarkeuw glad to hear it!! another thing-- it seemed to skip some photos at 1,000 ms, so I changed the 1000 to 2000 or 3000, something like that. it runs a lot slower then but also seems to prevent it from getting stuck :)

Copy link

Puigdo commented Jan 20, 2019

@caseklim Hello, I am trying to follow all the steps, however, this link https://www.facebook.com/search/YOUR_ID_NUM_HERE/photos-of/intersect is not working for me anymore. Which one did you use? Thank you very much in advanced! :)

@SirRodneySmodge
Copy link

SirRodneySmodge commented Jan 20, 2019 via email

@Puigdo
Copy link

Puigdo commented Jan 20, 2019

Hello @SirRodneySmodge , I replaced my FB ID but it says that it's not a valid link. The FB ID that I put on it is correct. Maybe I should modify something else from this link?
This is the only thing that I need to fix in order to finish this since I already tried to download some pictures using the terminal and it works fine. Thank you!!

Copy link

@Puigdo try using just the regular "Photos of Me" page!

Copy link

Hi, This doesn't seem to be working for me, as it downloads the html but not the photo. The code I am running in powershell:

\code
(type .\Desktop\photosOfMeList.txt) -replace "2VM364:1 ", "" | Out-File -FilePath .\Desktop\photosOfMeListClean.txt
$photoList = type .\Desktop\photosOfMeListClean.txt
$client = New-Object System.Net.WebClient
foreach ($photo in $photoList) {
$photoFileName = $photo.Substring($photo.length-10,$_+10)
$client.DownloadFile($photo,".\Desktop\photosOfMe" + $photoFileName + ".jpg")
}
\code

Can anyone verify if it still works on Unix OS, or windows and I am doing something wrong?

Copy link

My solution works for Windows 10, no powershell, just a website, a chrome extension and your finger.

If no one else has mentioned if you are using chrome, pressing F12 then selecting Console, this is the window they are having you enter the above text into, it will spit out your links.

Thanks to @SirRodneySmodge for the following as i used it and it worked:
for (link of document.getElementsByTagName('a')) { if (!link.href.includes("?fbid=")) continue; console.log("https://m.facebook.com/photo/view_full_size/?fbid=" + new URL(link.href).searchParams.get("fbid")); }

The console in chrome spits out the list and I copy and pasted it into notepad, and using find and replace to remove the non-URL text, example "2VM364:1 " i cleaned the document up.

Then i went to:
https://www.10bestseo.com/url-opener/
and pasted links in (and after stopping chrome from preventing popups on that website), it opened all of my photos. Yes hundreds of chrome tabs....

Then, i used the Tab save extension once they have all finally opened to download them:
https://chrome.google.com/webstore/detail/tab-save/lkngoeaeclaebmpkgapchgjdbaekacki

The only downside to this method is that you have to click save over and over for every photo but, that didn't take me too long for my 300 photos... you could always script something to click it if you had thousands of photos.

Copy link

xaviripo commented Apr 18, 2019

Hi! I created a script that worked for me. A little Python understanding may be required, specially in case one wants to adapt the solution to their own needs. The code is available here: https://github.com/xaviripo/fmpd.
If anyone has any doubts about it just ask me!

Edit: I have been working on refining this a bit; now it uses TypeScript (Deno) instead of Python. Take a look if you need to download big amounts of pictures using their FBIDs.

@scuba-st3v3
Copy link

@xaviripo thanks this tool saved me a lot of time!

@AmeliaMN
Copy link

Yeah, that link doesn't seem to work anymore (and yes, I've inserted my FB ID number into the URL). Anyone have an idea for a new one?

Copy link

@AmeliaMN, I got in and got all of my links, I'm having trouble with the import using wget, but I'm working on it.

I did this from chrome, i'm not sure how it works in other browsers:

To get the photo locations that he is telling you to copy into a txt file,, navigate to your facebook page, and go to "photos"

this should open up the page view where you can see the "photos of you"

scroll all the way to the bottom so that all of the "photos of you" are visable

right click anywhere on the screen (if you're using chrome) and select "inspect"

on the right hand side of the screen you'll see the web developer screen, at the top of it, select 'console'

you'll get a bunch of "OMG DON"T DO IT! SOMEONE IS HACKING YOU!!!" message, you can clear this by clicking on the little "no" sign (think "no smoking sign" etc) on the top right, this will clear your console and leave you with a white page.

in the blank space, paste the link provided above by @Novack :

for (link of document.getElementsByTagName('a')) { if (!link.href.includes("?fbid=")) continue; console.log("https://m.facebook.com/photo/view_full_size/?fbid=" + new URL(link.href).searchParams.get("fbid")); }

this will give you a list of all of the pictures by their web address, copy and paste it into a .txt file

i'm stuck on getting wget to extract them to my pc, but I'm hopeful I can get it figured out soon (anyone who has any ideas, I'd love to hear them!)

Copy link

@xaviripo , I'm attempting to run your script, getting the following error (sorry, I'm not familiar with python, and only minimally competent in ruby. Any help you can give would be appreciated!):

File "C:\Program Files (x86)\fmpd-master\download.py", line 24, in
final = re.search(r'(?<=url=).*?(?=")', redirect).group(0).replace('&', '&')
File "C:\Users\aubre\AppData\Local\Programs\Python\Python38-32\lib\re.py", line 199, in search
return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object

Copy link

@realmikeclarke So sorry for the unorthodox contact method but I'd really love to talk to you about whether I could take over your domain name. Have you seen my comment come through on your blog? It would really help me gain traction with my small business. Let me know if you're willing to talk through the options. -Hilary D.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests