6 from datetime
import datetime, timezone
136 if (imtype ==
'webformat'):
138 elif (imtype ==
'largeImage'):
140 elif (imtype ==
'preview'):
143 raise ValueError(
'supported types is webformat, largeImage and preview.', imtype,
'unsupported')
145 r = requests.get(uri, allow_redirects=
True)
147 if (r.status_code != 200):
148 raise ValueError(
'Pixabay return status code != 200 for uri', uri,
'Invalid parameters?')
157 with open(dst,
'wb')
as handler:
166 match = re.search(
'\d{4}/\d{2}/\d{2}/\d{2}/\d{2}', preview_url)
168 parts = match.group().split(
'/')
169 return datetime(int(parts[0]), int(parts[1]), int(parts[2]), int(parts[3]), int(parts[4]), tzinfo=timezone.utc)
172 match = re.search(
'\d{4}/\d{2}/\d{2}', preview_url)
174 parts = match.group().split(
'/')
175 return datetime(int(parts[0]), int(parts[1]), int(parts[2]), tzinfo=timezone.utc)
def getPreviewHeight(self)
Get Height of Preview.
def getViews(self)
Get views of image.
def getPublishedDate(self)
Get published date of image.
def getWebformatHeight(self)
Get height of webformat.
def getTags(self)
Get tags of image.
def getImageHeight(self)
Get height of image.
def getPreviewURL(self)
Get url of Preview.
def getId(self)
Get ID of image.
def getImageSize(self)
Get size of image.
def getUser(self)
Get name of author of image.
def getWebformatURL(self)
Get webformat URL.
def getPageURL(self)
Get page url of image.
def __init__(self, data)
Init image object.
def getUserImageURL(self)
Get url of image of author of image.
def getPreviewWidth(self)
Get width of Preview.
def getComments(self)
Get comments of image.
def getCollections(self)
Get collections of image.
def getType(self)
Get type of image.
def download(self, dst, imtype='webformat')
Download image to file.
def downloadRaw(self, imtype='webformat')
Download image to varaible.
def getLargeImageURL(self)
Get large Image URL.
def getUserId(self)
Get author id of image.
def getWebformatWidth(self)
Get width of webformat.
def getDownloads(self)
Get downloads of image.
def getLikes(self)
Get likes of image.
def getImageWidth(self)
Get width of image.