Issue
I have following xpath for YT comment owner's thumbnail.
<a class="yt-simple-endpoint style-scope ytd-comment-renderer" href="/channel/UCX6OQ3DkcsbYNE6H8uQQuVA">
<yt-img-shadow fit="" height="40" width="40" class="style-scope ytd-comment-renderer no-transition" loaded="" style="background-color: transparent;"><!--css-build:shady--><img id="img" draggable="false" class="style-scope yt-img-shadow" alt="MrBeast" height="40" width="40" src="https://yt3.ggpht.com/ytc/AMLnZu_NBXmT9J0H9uL94tZm6YxOGdMn0utqYJh1aQlv4A=s88-c-k-c0x00ffffff-no-rj"></yt-img-shadow>
</a>
I can get the url value of image from src as
https://yt3.ggpht.com/ytc/AMLnZu_NBXmT9J0H9uL94tZm6YxOGdMn0utqYJh1aQlv4A=s88-c-k-c0x00ffffff-no-rj
Could anyone please tell me how to download this image using python ?
Solution
You can do it by using urlib.request package
Here, you can simply pass the image URL(from where you want to download and save the image) and directory(where you want to save the download image locally, and give the image name with .jpg or .png) Here I given "local-filename.jpg" replace with this.
Example
import urllib.request
imgURL = "http://site.meishij.net/r/58/25/3568808/a3568808_142682562777944.jpg"
urllib.request.urlretrieve(imgURL, "D:/abc/image/local-filename.jpg")
Answered By - Akzy
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.