使用直接路径(不是链接)从Google下载图像

Google图片具有此怪异的path元素,当将其输入浏览器时,会将您直接带到该图片(即

数据:图像/ PNG; BASE64,iVBORw0KGgoAAAANSUhEUgAAAM4AAAD1CAMAAAAvfDqYAAAAflBMVEUAAAD //// 09PTa2tr7 + / + uqqqrW1tbs7OxoaGh1dXXn5 + fKysrAwMBSUlKjo6Pf39 + VlZWxsbG3t7c + Pj5LS0uampqEhISvr68eHh5DQ0PMzMxgYGBlZWUXFxczMzPv7 + 8nJyeMjIxxcXEwMDBYWFgaGhoQEBB fn5OTk6IiIhJAEQBAAAI2UlEQVR4nNWd6XriOgyGlRAoSwoUCm3htCXTDszc / w2esmexJVnJ2Nb3H9vvg + NFmyGJT1nvqRg + w0DwU + h8MC21KT7grFzw67hw8iHctRA0EBHOeA0VvQjaiAZn8gw19QWtRIKzeK3DKMbJDTAAT4KWIsDpLU0wSpeCbGSGAZgIWguNk9tgQOM2 + P + dBh4E7QXF6SEwIBpZSJw + SrOTNBkQ54DSwFDSZjicb5wGVpJGg + G8ETSwkbQaCseydZaUSZoNhNM4bza0FLUbBmdL0sg + nTA4a5oGeqKWQ + A8MWj2sqYD4MwYNDCXtR0Ah0MDY2Hb3Q6VIcYyAPAsbNw7zoL150iMUkf5xklZNMKFwD8OdVI7S2KTOskzzoRFIx + UZ5w9i0Zi9DjLL86URfMl78ArTsabahKbx0VeceYsGtE19CKvOLw / R3TRufbQ2VhprVg08nUg8YvDovmvXRcdDZUhxOBZUrs + POI8cmhkt7ab / OF8cmgkPp2y / OFwttBfbTvxh0Ma1gDeWnfiDYdxM3ht34s3HMa1LW3fizccq5Ptps8OevGG85uikXinGvKFQ346ndB4w9ngMO8dfDdH + cLBPW3LNqfosnzhoGbpNjecqnzhYMbCaXfd + ML5sNO0PHVW5AvHCtP6mFbtptPWkH4skkSqYN1025y9H6OKzrvpukFbPwaNujjW1LrpvEVLPw2tuzkH1Lr5B20a + 6nqo + 2109bNv2m2oV2J5XEq9K 3R8oVztnt8bNcvXW4zDbXASce9zSTf9Lr7BrLBYj76 /没有/ KU + EH3 + NEC / xMCfByQb99eN7afbst / O8LdRgOjR7S37a5q + ArjhpftgZe / 3Z35 + kSLMpYYPbjxa8G4QTznhFRAbtCndnxoSIa7tqyVlA + DhZHzlGlrR2IZrQJoQyUZ / 6lLg4M5d + ixmrzd5fF5azRnjTPJwNHbBV1deUmusPK2NoO61nLG6PgzNgGDCb + kZCHdIXUZMXvdmnM43zwAsFMOmX8fifLeQtXrS1raEkTtGu41HtP0qfWrOcZImoInAIexJL2 / 51hZ1N28yxql6NawKO47SMYtoW / RUWoC + RKbwSw5m9022G1HNzF0JwcEtfFGpMODvOr9Bj5ai + GVhx6LjtKFS71Vpw0sg / m7tWDJxx6EE6aEXiaKKpzjcTzkPoAToqR3F40acxqYfhCA / uIZXacbo7VvnThxWns2OaVx0sOC + hBybU2Iija4m + 6C / VElfDUXMYqOieO1 / FYZq84tKyZCSt4HRx9 / SuokxQwQk9MomqZqoyjsCKF1qvNWt8CUfhqtZIwirhuFo6w6sZ / HLHYabWRKRRg6aEo + 7kaaC54 / BS7CKSMfrlhsPLe4pH3yaaG462P + fDSHPD2YUen6Ms7qMLjrbjjc3Dc8HpxkvhTdZiBmccZbYbe67CGYeXYxeN7GETZ5zQ43MTEgp7whmEHqCTsPJGJxxdl1DSER96gE76g9CccHTNNTQe7oijal3Dy2YccXihQ5EID7wGZR6Dd5TmiMPLto1ERPoFKDPgEHGUoMZHfRJVPwd07TpUNDkQ5R8jExU8C6x6XLGIzPsFVrG0WHSgcVhlBCIRWTgDVK0EZCQ1MGvXxCGKJgFNfgO6ngFoMkmZrNI1HE3mT7q4JvCqWMUhuiIQtIyT9io6yRQ0mT3oPDMY0q1EIzqBBzRZp + kMK9Dk4GXgaLq8MXB2ocfoIAaOJoc1A0dTyBedP6oKh7FQa5psjG 10F3qMDmIccjQZqOkHhlRto3RFdPgTeowOoovQAKsWeSSin3oAVVHtNI6m + w7DMKXKk0ibDRWkU95FG3U1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ZY1I / 9wusL + VRKcpIfcGN7njElWV44lsRPPVVUkwvmZ9GaLyO + CPclqynLzZ7Tk / zNHCXF + 1ux5 / RK07Qv + l7J609qf9Dh1bVGM86Pxotgu97DfPY5WeUuUq9LBYlocRodimlsNAoj + B6EbdnLOwM4vAAAAAElFTkSuQmCC

为您带来Apple公司徽标的图片)。给定此链接,有什么方法可以下载图像? 请求和request_html无法访问这种类型的路径。

评论
转身说再见
转身说再见

这是图像的base64编码。如果仅将其作为字符串并在对base64进行解码后保存到磁盘,它将正确保存为png。

从这个答案:

# your string is 
img_data = 'iVBORw0KGgoAAAANSUhEUgAAAM4AAAD1CAMAAAAvfDqYAAAAflB'...

# For both Python 2.7 and Python 3.x
import base64
with open("imageToSave.png", "wb") as fh:
    fh.write(base64.decodebytes(img_data))

Convert string in base64 to image and save on filesystem in Python

点赞
评论
Max
Max

这些字母和数字就是图片。从字面上看。它只是base64编码的。

因此,您可以做的一件事就是导入base64库,以将该字符串转换为映像,然后可以将其保存到磁盘。

See https://stackoverflow.com/a/37767000/1831109

点赞
评论