刮脸书个人资料图片链接蟒蛇3硒



使用python3、selenium 获取facebook个人资料图片链接的问题很热门

当检查配置文件照片元素时,它给出:

<image style="height: 168px; width: 168px;" x="0" y="0" height="100%" preserveAspectRatio="xMidYMid slice" width="100%" xlink:href="https://scontent.fskp2-1.fna.fbcdn.net/v/t1.0-1/p160x160/66377281_10219519738489211_3470999363818356736_n.jpg?_nc_cat=102&amp;_nc_ohc=wwARRHDG764AX8QTDeA&amp;_nc_ht=scontent.fskp2-1.fna&amp;_nc_tp=6&amp;oh=af9af2ffed61664c18229d3474cea541&amp;oe=5ECC34A6"></image>  

但是,$x("//image"(给出0个结果。我已经登录了facebook。有什么提示吗?

下面是我解决这个问题的方法。

通过浏览器(selenium(进行全屏截图,然后将照片剪切到精确的坐标。

# selenium imports
from PIL import Image
...
driver.save_screenshot("shot.png")
x = 100
y = 80
w = 200
h = 220
width = x + w
height = y + h
im = Image.open('shot.png')
im = im.crop((int(x), int(y), int(width), int(height)))
im.save('image.png')

最新更新