diff options
author | emkael <emkael@tlen.pl> | 2024-11-25 23:24:26 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2024-11-25 23:24:26 +0100 |
commit | 07dc74d9e73585d840854c642523f0fc05075df8 (patch) | |
tree | a76bf82f6faee22a57bd6834595894161c98700c /bin | |
parent | 373141ac8765c76f06c496a51b320852447c20ba (diff) |
Fuck off, Zuck
Diffstat (limited to 'bin')
-rw-r--r-- | bin/fb-scrape/get-fb-content.py | 7 | ||||
-rw-r--r-- | bin/fb-scrape/requirements.txt | 2 | ||||
-rwxr-xr-x | bin/refresh-fb-cache.php | 8 |
3 files changed, 12 insertions, 5 deletions
diff --git a/bin/fb-scrape/get-fb-content.py b/bin/fb-scrape/get-fb-content.py index 5b22f70..6d6b7ba 100644 --- a/bin/fb-scrape/get-fb-content.py +++ b/bin/fb-scrape/get-fb-content.py @@ -8,6 +8,7 @@ from pytz_deprecation_shim import PytzUsageWarning from random import randint from facebook_scraper import get_posts, enable_logging +from facebook_scraper.exceptions import TemporarilyBanned from requests.exceptions import RequestException debug = len(sys.argv) > 2 and sys.argv[2] == 'debug' @@ -21,6 +22,10 @@ warnings.filterwarnings( ) warnings.filterwarnings( action='ignore', + message=r"Facebook says 'Unsupported Browser'" +) +warnings.filterwarnings( + action='ignore', category=PytzUsageWarning ) @@ -36,7 +41,7 @@ try: 'images': post['images'] }) time.sleep(randint(10, 15)) -except RequestException: +except (RequestException, TemporarilyBanned): pass print(json.dumps(posts)) diff --git a/bin/fb-scrape/requirements.txt b/bin/fb-scrape/requirements.txt new file mode 100644 index 0000000..6632c5e --- /dev/null +++ b/bin/fb-scrape/requirements.txt @@ -0,0 +1,2 @@ +facebook-scraper +pytz-deprecation-shim diff --git a/bin/refresh-fb-cache.php b/bin/refresh-fb-cache.php index ca50146..6a841de 100755 --- a/bin/refresh-fb-cache.php +++ b/bin/refresh-fb-cache.php @@ -13,7 +13,7 @@ $cacheFiles = glob('../cache/facebook.*'); $fileToFetch = NULL; $oldestCache = PHP_INT_MAX; -foreach ($cacheFiles as $file) { +/*foreach ($cacheFiles as $file) { if (!preg_match('/\.Piwoteka$/', $file)) { $cacheTime = filemtime($file); if ($cacheTime < $oldestCache) { @@ -23,12 +23,12 @@ foreach ($cacheFiles as $file) { $fileToFetch = implode('.', $fileToFetch); } } -} + }*/ -$filesToFetch = ['Piwoteka', 'fermentlodz', $fileToFetch]; +$filesToFetch = ['Piwoteka', 'EtreGourmet']; //, $fileToFetch]; foreach ($filesToFetch as $feed) { - sleep(rand(60, 90)); + sleep(rand(90, 120)); $provider = new \Providers\Facebook($feed, ['force' => TRUE]); if (!$provider->get()) { throw new \Exception(sprintf('Feed %s failed to fetch!', $feed)); |