• 0

Good way to list the contents of a dropbox folder in php


Question

4 answers to this question

Recommended Posts

  • 0

This is the scraper that I have so far:


<?php

// Get drobox folder html.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.dropbox.com/sh/mneh7sehw63cvk6/VcWEokE4yH' ); // Dropbox shared folder link
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (FM Scene 4.6.1)');
curl_setopt($ch, CURLOPT_REFERER, 'https://www.dropbox.com/');
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$html =curl_exec ($ch);
// extract links with DOMDocument
$dom = new DOMDocument();
@$dom->loadHTML($html);
$links = $dom->getElementsByTagName('a');
$processed_links = array();
foreach ($links as $link)
{
if ($link->hasAttribute('class')&& $link->hasAttribute('href'))
{
foreach ($link->attributes as $a)
{
if ($a->value=='filename-link')
{
$processed_links[$link->getAttribute('href')] = $link->getAttribute('href');
}

}

}
}


echo var_dump($processed_links);




?>
[/CODE]

  • 0

Why are you scraping a webpage when Dropbox have an API?

edit; sorry, my mistake, after looking through the Dropbox API for some reason it seems like they have a call to access shared/public folders. :huh:

  • 0
  On 22/03/2013 at 18:18, ZakO said:

Why are you scraping a webpage when Dropbox have an API?

edit; sorry, my mistake, after looking through the Dropbox API for some reason it seems like they have a call to access shared/public folders. :huh:

I found it's odd that they don't allow to simply list a directory like this without OAuth.

I managed to put together something with the scraper to get all images and txt files and display them. Seems to work ok :


<?php

// Get drobox folder html.
$folder = 'https://www.dropbox.com/sh/mneh7sehw63cvk6/VcWEokE4yH'; // Dropbox shared folder link
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $folder);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (FM Scene 4.6.1)');
curl_setopt($ch, CURLOPT_REFERER, 'https://www.dropbox.com/');
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$html =curl_exec ($ch);
// extract links with DOMDocument
$dom = new DOMDocument();
@$dom->loadHTML($html);
$links = $dom->getElementsByTagName('a');
$processed_links = array();
foreach ($links as $link)
{
if ($link->hasAttribute('class')&& $link->hasAttribute('href'))
{
foreach ($link->attributes as $a)
{
if ($a->value=='filename-link')
{
$processed_links[$link->getAttribute('href')] = $link->getAttribute('href');
}

}

}
}

$exts = $processed_links;
foreach ($exts as $ext)
{
$url = $ext;

$path = parse_url($url, PHP_URL_PATH);

$ext2 = pathinfo($path, PATHINFO_EXTENSION);

// echo "<br> <a href=https://dl.dropbox.com$path>http://dl.dropbox.com$path</a

if ($ext2 == 'jpg')
{
echo "<br> <a href=https://dl.dropbox.com$path><imghhttps://dl.dropbox.com$path></img></a
//echo $path;
}
if ($ext2 == 'txt')
{
$first = "https://dl.dropbox.com";

$ch2 = curl_init();
curl_setopt($ch2, CURLOPT_URL, $first.$path); // textfile
curl_setopt($ch2, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (FM Scene 4.6.1)');
curl_setopt($ch2, CURLOPT_REFERER, 'https://www.dropbox.com/');
curl_setopt($ch2, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch2, CURLOPT_AUTOREFERER, true);
curl_setopt($ch2, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch2, CURLOPT_TIMEOUT, 5);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
$str =curl_exec ($ch2);
//echo preg_replace('!\r?\n!', '<br>', $str);
echo '<pre>';
echo preg_replace('!\r?\n!', '<br>', $str);
echo '</pre>';
}
}

?>
[/CODE]

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • The Start menu in Windows 11 is the Start menu I dislike the most.
    • Apple's AI models still trail behind OpenAI's GPT-4o despite latest update by Pradeep Viswanathan At WWDC 2025, Apple announced several updates related to Apple Intelligence for both developers and consumers. With the new Foundation Models framework, developers can now bring AI experiences to their apps that work offline in a privacy-preserving way and are available free of charge. The Foundation Models framework is built on Apple’s own in-house-developed AI models. Apple also unveiled a new generation of language foundation models. According to Apple, these updated models are faster, more efficient, and offer improved tool use, better reasoning capabilities, multimodal support for image and text inputs, and support for 15 languages. Apple Intelligence includes two foundation models: A 3-billion-parameter model that runs on-device using Apple Silicon. A server-based mixture-of-experts model optimized for Private Cloud Compute. Apple noted that the on-device 3B language model is not designed to be a general-purpose chatbot. Instead, it is intended to perform text-related tasks such as summarization, entity extraction, text understanding, refinement, short dialogues, and creative content generation, among others. The big question is how well Apple’s models perform compared to other leading models on the market. Rather than using standard AI benchmarks, Apple shared results from its own internal evaluations of fundamental language and reasoning capabilities. According to Apple’s text-based evaluations, its on-device 3B model performs favorably against the slightly larger Qwen-2.5-3B and competitively against the larger Qwen-3-4B and Gemma-3-4B in English. Its server-based model performs slightly better than Llama-4-Scout but falls short compared to Qwen-3-235B and OpenAI’s proprietary GPT-4o. In evaluations involving image input, Apple’s on-device model outperforms InternVL and Qwen, and performs competitively against Gemma. While Apple’s server model beats Qwen-2.5-VL, it underperforms when compared to Llama-4-Scout and GPT-4o. These results highlight how far Apple still has to go in foundational AI capabilities. It seems Apple compared its models to GPT-4o to make its performance appear relatively decent. If Apple were to compare its results against OpenAI’s latest O-series models or Google’s Gemini 2.5 Pro, the gap would likely appear much wider. It will be interesting to see how Apple navigates the AI era with its in-house capabilities in the years ahead.
    • Voe 3 video generation has gone viral. Especially with audio they look realistic. People posting tons of wild videos created by ai is insane
    • Vive tool again. Sigh, no thanks.
  • Recent Achievements

    • Week One Done
      IAMFLUXX earned a badge
      Week One Done
    • One Month Later
      Æhund earned a badge
      One Month Later
    • One Month Later
      CoolRaoul earned a badge
      One Month Later
    • First Post
      Kurotama earned a badge
      First Post
    • Collaborator
      Carltonbar earned a badge
      Collaborator
  • Popular Contributors

    1. 1
      +primortal
      492
    2. 2
      ATLien_0
      268
    3. 3
      +FloatingFatMan
      231
    4. 4
      +Edouard
      199
    5. 5
      snowy owl
      153
  • Tell a friend

    Love Neowin? Tell a friend!