0

I'd like to download Files hosted on Facebook group which I'm part of.

I couldn't find any relevant API, and the following question at Quora points to extensions which are outdated.

The first challenge is to click on See more to see all the files, then click them one by one. Sometimes after See more, the AJAX loading is stuck, so the whole page needs to be refresh and started again.

How this can be achieved?

0

The following steps can be used:

  1. Navigate to Files page on Facebook using your web-browser.
  2. Using DevTools JS Console in web-browser, run the following code (ignore the red Stop sign):

    setInterval(function() { document.getElementsByClassName("uiMorePagerPrimary")[0].click(); }, 20000);
    

    The script is going to click See more button every 20 seconds, even when it's stuck.

  3. When page is fully loaded, extract all links into urls variable.

    var urls = [];
    for (var i = document.links.length; i --> 0;) if (document.links[i].href.includes("download")) urls.push(document.links[i].href);
    

    Source: How to get all the URLs in a web site using JavaScript?

  4. Optionally you can print the links using console.log(urls) or console.table(urls).

  5. Copy the links to clipboard by running: copy(urls.join("\n")) and paste into the text file.
  6. From the Network tab of DevTools, pick one request and Copy as cURL (not all).
  7. Convert into wget by making the following adjustments to the command (as per this post):

    • Change curl to wget (1st string from the left).
    • Remove the URL (2nd string from the left).
    • Remove --compress parameter.
    • Change -H to --header in all places.
    • Add -nc or -c to not re-download the existing files.
    • Add --content-disposition parameter.
    • Point to the text file with the list by adding: -i list.txt.

    Note: If you're Vim user, run set -o vi, type command, and hit Esc+V, to edit shell command in Vim.

  8. Run above converted command, to start downloading the files. It should looks like:

    wget --header '...' --header '...' --content-disposition -c -i list.txt 
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.