:::
Tad Google 相簿

google相簿是不是無法擷取相片了?

discuss pic 2024-08-01 17:18:00

有學校反映七月中還能擷取成功,這幾天都失敗,剛才測試以前有成功擷取相片的相簿現在無法擷取,不知發生甚麼問題

discuss pic 2024-08-02 07:52:57
tad

請給我個測試用的分享相簿網址,我試試

discuss pic 2024-08-02 08:17:46
這是給「hirokofan」的悄悄話喔!
discuss pic 2024-08-02 08:32:47
tad

修改一下 \modules\tad_gphotos\class\Crawler.php 裡面的getAlbum($url)

public function getAlbum($url)
    {
        $response = $this->client->get($url, ['http_errors' => false]);
        if ($response->getStatusCode() !== 200) {
            return false;
        }
        $html = $response->getBody()->getContents();

        $re = '/<script class="ds:1" nonce="[^"]+">AF_initDataCallback\(\{[^<]+, data:([^<]+)\}\);<\/script>/m';
        preg_match_all($re, $html, $matches, PREG_SET_ORDER, 0);

        $json = $matches[0][1];
        $json = str_replace(", sideChannel: {}", '', $json);
        $data = json_decode($json, true);
        $images = array_map(function ($image) {
            return [
                'id' => $image[0],
                // default url
                'url' => $image[1][0],
                // max size
                'width' => $image[1][1],
                'height' => $image[1][2],
            ];
        }, $data[1]);
        $this->data = [
            'id' => $data[3][0],
            'name' => $data[3][1],
            'images' => $images,
        ];
        return $this->data;
    }

 

discuss pic 2024-08-02 08:51:06

OK了,感謝!

discuss pic 2024-08-02 08:57:35
tad

提醒一下,tad_web 也要改喔

:::

快速登入


https%3A%2F%2Fcampus-xoops.tn.edu.tw%2Fmodules%2Ftad_discuss%2Fdiscuss.php%3FBoardID%3D67%26DiscussID%3D10547%26g2p%3D1

計數器

今天: 4592459245924592
昨天: 2489248924892489
總計: 8026574802657480265748026574802657480265748026574