mirror of
https://github.com/saurabhan/Wallhaven-dl.git
synced 2026-01-07 10:28:02 +00:00
Added currentImage/totalImage
This commit is contained in:
@@ -118,8 +118,9 @@ def main():
|
|||||||
|
|
||||||
pgid = int(input('How Many pages you want to Download: '))
|
pgid = int(input('How Many pages you want to Download: '))
|
||||||
print('Number of Wallpapers to Download: ' + str(24 * pgid))
|
print('Number of Wallpapers to Download: ' + str(24 * pgid))
|
||||||
for i in range(1, pgid + 1):
|
for j in range(1, pgid + 1):
|
||||||
url = BASEURL + str(i)
|
totalImage = str(24 * pgid)
|
||||||
|
url = BASEURL + str(j)
|
||||||
urlreq = requests.get(url, cookies=cookies)
|
urlreq = requests.get(url, cookies=cookies)
|
||||||
soup = bs4.BeautifulSoup(urlreq.text, 'lxml')
|
soup = bs4.BeautifulSoup(urlreq.text, 'lxml')
|
||||||
soupid = soup.findAll('a', {'class': 'preview'})
|
soupid = soup.findAll('a', {'class': 'preview'})
|
||||||
@@ -127,6 +128,7 @@ def main():
|
|||||||
imgid = res.findall(str(soupid))
|
imgid = res.findall(str(soupid))
|
||||||
imgext = ['jpg', 'png', 'bmp']
|
imgext = ['jpg', 'png', 'bmp']
|
||||||
for i in range(len(imgid)):
|
for i in range(len(imgid)):
|
||||||
|
currentImage = (((j - 1) * 24) + (i + 1))
|
||||||
url = 'http://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-%s.' % imgid[
|
url = 'http://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-%s.' % imgid[
|
||||||
i]
|
i]
|
||||||
for ext in imgext:
|
for ext in imgext:
|
||||||
@@ -135,12 +137,13 @@ def main():
|
|||||||
if not os.path.exists(osPath):
|
if not os.path.exists(osPath):
|
||||||
imgreq = requests.get(iurl, cookies=cookies)
|
imgreq = requests.get(iurl, cookies=cookies)
|
||||||
if imgreq.status_code == 200:
|
if imgreq.status_code == 200:
|
||||||
|
print("Downloading : %s - %s / %s" % ((os.path.basename(iurl)), currentImage , totalImage))
|
||||||
with open(osPath, 'ab') as imageFile:
|
with open(osPath, 'ab') as imageFile:
|
||||||
for chunk in imgreq.iter_content(1024):
|
for chunk in imgreq.iter_content(1024):
|
||||||
imageFile.write(chunk)
|
imageFile.write(chunk)
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print("%s already exist" % os.path.basename(iurl))
|
print("%s already exist - %s / %s" % os.path.basename(iurl), currentImage , totalImage)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user