Initial commit
This commit is contained in:
commit
bce6731494
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.pip
|
||||||
|
*.jpg
|
24
LICENSE.txt
Normal file
24
LICENSE.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
This is free and unencumbered software released into the public domain.
|
||||||
|
|
||||||
|
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||||
|
distribute this software, either in source code form or as a compiled
|
||||||
|
binary, for any purpose, commercial or non-commercial, and by any
|
||||||
|
means.
|
||||||
|
|
||||||
|
In jurisdictions that recognize copyright laws, the author or authors
|
||||||
|
of this software dedicate any and all copyright interest in the
|
||||||
|
software to the public domain. We make this dedication for the benefit
|
||||||
|
of the public at large and to the detriment of our heirs and
|
||||||
|
successors. We intend this dedication to be an overt act of
|
||||||
|
relinquishment in perpetuity of all present and future rights to this
|
||||||
|
software under copyright law.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||||
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
For more information, please refer to <http://unlicense.org>
|
1
images/.stanis-tits.latest
Normal file
1
images/.stanis-tits.latest
Normal file
@ -0,0 +1 @@
|
|||||||
|
0
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
requests==2.11.1
|
||||||
|
beautifulsoup4==4.5.1
|
52
stanis-tits.py
Normal file
52
stanis-tits.py
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
sys.path.append('./.pip')
|
||||||
|
import requests
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import os.path
|
||||||
|
|
||||||
|
__author__ = 'Alexander Popov'
|
||||||
|
__version__ = '0.0.1'
|
||||||
|
__license__ = 'Unlicense'
|
||||||
|
|
||||||
|
IMAGES_DIR = './images'
|
||||||
|
COOKIES = dict(block='951')
|
||||||
|
URL = 'http://blog.stanis.ru/?back=%d'
|
||||||
|
PAGE = 0
|
||||||
|
with open('%s/.stanis-tits.latest' % IMAGES_DIR, 'r') as f:
|
||||||
|
LATEST_FILE = f.read()
|
||||||
|
STOP = False
|
||||||
|
NEXT_LATEST = None
|
||||||
|
|
||||||
|
while STOP == False:
|
||||||
|
print('Loading page %d' % PAGE)
|
||||||
|
|
||||||
|
r = requests.get(URL % PAGE, cookies=COOKIES)
|
||||||
|
|
||||||
|
|
||||||
|
soup = BeautifulSoup(r.text.encode('cp1251'),
|
||||||
|
"html.parser", from_encoding="windows-1251")
|
||||||
|
images = soup.findAll('img', src=re.compile('img/*'))
|
||||||
|
|
||||||
|
for image in images:
|
||||||
|
if int(image['src'].split('/')[1].split('.')[0]) == int(LATEST_FILE):
|
||||||
|
STOP = True
|
||||||
|
|
||||||
|
if PAGE == 0:
|
||||||
|
if NEXT_LATEST == None:
|
||||||
|
NEXT_LATEST = str(image['src'].split('/')[1].split('.')[0])
|
||||||
|
with open('%s/.stanis-tits.latest' % IMAGES_DIR, 'w+') as f:
|
||||||
|
f.write(NEXT_LATEST)
|
||||||
|
|
||||||
|
if not os.path.exists('%s/%s' % (IMAGES_DIR, image['src'].split('/')[1],)):
|
||||||
|
print('\tDownload %s' % image['src'].split('/')[1])
|
||||||
|
response = requests.get('http://blog.stanis.ru/%s' % image['src'], stream=True)
|
||||||
|
|
||||||
|
with open('%s/%s' % (IMAGES_DIR, image['src'].split('/')[1]), 'wb') as out_image:
|
||||||
|
shutil.copyfileobj(response.raw, out_image,)
|
||||||
|
|
||||||
|
PAGE += 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user