naver-blog-backer
naver-blog-backer๋ ๋ค์ด๋ฒ ๋ธ๋ก๊ทธ๋ฅผ ๋ฐฑ์
(ํฌ๋กค๋ง)๊ณผ ๋ฐฑ๋งํฌ ๋ API๋ฅผ ์ ๊ณตํ๋ ํจํค์ง์
๋๋ค.
- ๋ฐฑ์
(crawling) API๋ ๊ฐ์ธ ๋ค์ด๋ฒ ๋ธ๋ก๊ทธ์ ๊ธ์ ์์นด์ด๋น ๋ชฉ์ ์ผ๋ก ๊ธฐ์กด ํฌ์คํธ๋ฅผ ๋งํฌ๋ค์ด์ธ์ด ํ์ผ๋ก ์ ์ฅํฉ๋๋ค.
- ๋ฐฑ๋งํฌ API๋ ๊ธฐ์กด ๋ค์ด๋ฒ ๋ธ๋ก๊ทธ ์ฌ์ฉ์๋ค์ ์ ๋ก์ฌํญ์ธ ๊ตฌ๊ธ ๊ฒ์ ์์ง์ ํฌ์คํธ๊ฐ ์ธ๋ฑ์ฑ ๋์ง ์๋ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํ ํฌ์คํธ ๋ฐฑ๋งํฌ ํ
์คํธ ํ์ผ๋ก ์ ์ฅํฉ๋๋ค.
![](https://jeongseup.github.io/assets/naver-blog-backer/video/example_script.gif)
โป ์ผ๋ฐ ์ฌ์ฉ์๋ถ๋ค๊ป์๋ ํด๋น ํด๋ ๋ด์ ์์นํ 'naverblogbacker.exe'ํ์ผ์ ๋ค์ด ๋ฐ์ผ์๋ฉด ๋ฉ๋๋ค.
๋ณธ๋ ์์์ ํ๋ก๊ทธ๋จ์ ์คํ์ํค๋ ๊ฒ์ ํดํน ์ทจ์ฝํฉ๋๋ค. ๋ค์ด๋ก๋ ์ ๋ฐฑ์ ํ๋ก๊ทธ๋จ์ด๋ window defense์ ๊ฒ์ถ๋ ์ ์์ผ๋ ์์ฌํ์๊ธธ ๋ฐ๋๋๋ค :smile:
โป ํด๋น ํจํค์ง๋ ์๋์ ๋ ํจํค์ง๋ฅผ ์ฐธ๊ณ ํ์ฌ ๋ง๋ค์ด์ก์ต๋๋ค.
- https://github.com/Lenir/Naver-Blog-Backup
- https://github.com/chandong83/download-naver-blog
Installation
$ pip install naver-blog-backer
Usage
naverblogbacker๋ crawling๊ณผ backlinking 2๊ฐ์ง ์๋น์ค๋ฅผ ์ ๊ณตํฉ๋๋ค.
- crawling use case
from naverblogbacker.utils import isEmptyDirectory
from naverblogbacker.blog import BlogCrawler
import os
myId = 'YOUR NAVER ID'
myPath = 'SAVE DIRECTROY PATH'
mySkipSticker = 'TRUE OR FALSE'
if isEmptyDirectory(dirPath=myPath):
myBlog = BlogCrawler(targetId=myId, skipSticker=mySkipSticker, isDevMode=False)
myBlog.crawling(dirPath=myPath)
print(f'[MESSAGE] Complete! your blog posts, the number of error posts is {BlogCrawler.errorPost}')
os.system("pause")
โป SAVE DIRECTORY PATH๋ ๋ฐ๋์ ๋น ํด๋์ฌ์ผ ํฉ๋๋ค. ๊ทธ๋ ์ง ์์ผ๋ฉด, ์๋ฌ๊ฐ ๋ฐ์ํ๊ณ ํ๋ก๊ทธ๋จ์ด ์ข
๋ฃ๋ฉ๋๋ค.
output
![](https://jeongseup.github.io/assets/naver-blog-backer/image/output_backup.png)
- backlink use case
from naverblogbacker.blog import BlogCrawler
import os
myId = 'YOUR NAVER ID'
myPath = 'SAVE DIRECTROY PATH'
myBlog = BlogCrawler(targetId=myId, skipSticker=mySkipSticker, isDevMode=False)
myBlog.backlinking(dirPath=myPath)
print(f' [MESSAGE] Complete! created your backlinks')
os.system("pause")
โป ๋ฐฑ๋งํฌ ์์ฑ api๋ ๋ฐ๋์ ๋น ํด๋์ผ ํ์๊ฐ ์์ต๋๋ค.
output
![](https://jeongseup.github.io/assets/naver-blog-backer/image/output_backlink.png)
Options
targetId
: ๋ฐฑ์
๋ฐ ๋ฐฑ๋งํฌ๋ฅผ ์ํ ์ฌ์ฉํ ๋ค์ด๋ฒ ๋ธ๋ก๊ทธ ์์ด๋์
๋๋ค.dirPath
: ๋ฐฑ์
ํน์ ๋ฐฑ๋งํฌ ๊ฒฐ๊ณผ๋ฌผ์ ์ ์ฅํ ๊ฒฝ๋ก์
๋๋ค.skipSticker
: (optional) ๋ธ๋ก๊ทธ ํฌ์คํธ ๋ด ์คํฐ์ปค ์ด๋ฏธ์ง๋ฅผ ์ ์ฅํ ์ง ๋ง์ง์ ๋ํ ์ต์
์
๋๋ค. ๊ธฐ๋ณธ๊ฐ์ True์ด๋ฉฐ, True๋ฅผ ์คํฐ์ปค ์ด๋ฏธ์ง๋ฅผ ์คํตํด ์ ์ฅํ์ง ์๋ ๊ฒ์ ๋ปํฉ๋๋ค.isDevMode
: (optional) naver-blog-backer ๋ชจ๋ ๋ด ์ฒ๋ฆฌ๋ค์ ๋ํ ์์ธ ํ์คํ ๋ฆฌ๋ฅผ ๋ณผ ์ ์๋ ๊ฐ๋ฐ์ ๋ชจ๋ ์ต์
์
๋๋ค. ๊ธฐ๋ณธ๊ฐ์ False์ด๋ฉฐ, ๋ง์ฝ True๋ก ์ ํ ์ [DEV MODE] ๋ฉ์ธ์ง๊ฐ ์ถ๋ ฅ๋ฉ๋๋ค.
Examples
- using pthon script (the code is tests folder in this repository)
import os
from naverblogbacker.utils import isEmptyDirectory
from naverblogbacker.blog import BlogCrawler
from pick import pick
def main(myId, myPath, myOption):
if myOption is 'backlink':
try:
myBlog = BlogCrawler(targetId=myId, skipSticker=True, isDevMode=False)
myBlog.backlinking(dirPath=myPath)
print(f' [MESSAGE] Complete! created your backlinks')
os.system("pause")
except Exception as e:
print(e)
os.system("pause")
elif myOption is 'backup':
try:
if not isEmptyDirectory(dirPath=myPath):
pass
myBlog = BlogCrawler(targetId=myId, skipSticker=True, isDevMode=False)
myBlog.crawling(dirPath=myPath)
print(f'[MESSAGE] Complete! your blog posts, the number of error posts is {BlogCrawler.errorPost}')
os.system("pause")
except Exception as e:
print(e)
os.system("pause")
else:
print(f' [MESSAGE] Sorry, It`s currently not supported')
os.system("pause")
if __name__ == '__main__':
myId = 'YOUR NAVER ID'
myPath = 'SAVE DIRECTORY'
myOption = 'CHOOSE OPTIONS IN [backlink, backup]'
main(myId, myPath, myOption)
sample
![](https://jeongseup.github.io/assets/naver-blog-backer/video/example_script.gif)
- using program (the program, naverblogbacker.exe, is root path in this repository)
sample
![](https://jeongseup.github.io/assets/naver-blog-backer/video/example_exe.gif)
Notes
Notations
ํ์ฌ ์ด ํจํค์ง๋ ๋ค์ด๋ฒ ๋ธ๋ก๊ทธ ์๋ํฐ ๋ฒ์ ผ 4๋ง์ ์ง์ํฉ๋๋ค. (์ค๋งํธ ์๋ํฐ one) ๋ง์ฝ ๋ฐฑ์
ํ ์ ์๋ ๋ฒ์ ผ์ ํฌ์คํธ๋ฅผ ๋ง์ฃผํ๊ฒ ๋๋ฉด ์๋์ผ๋ก ์ข
๋ฃํฉ๋๋ค.
Version Information
ver 0.0.1 ~ 0.0.6
Test bed
ver 0.0.7
EXE packing
ver 0.0.8
Add authentication & GUI version serving
Later
it will be making GUI version for common users
Memo
ํด๋น ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฐ ํ๋ก๊ทธ๋จ ๊ฐ๋ฐ๊ณผ ๊ด๋ จ๋ ๋ฉ๋ชจ๋ฅผ ์ํ ๊ณต๊ฐ์
๋๋ค.
package things
Naver blog editior things
์ง์ํ๋ ์๋ํฐ ๋ฒ์ ผ์ Component ๊ตฌ์ฑ์ ํฌ๊ฒ HEADER์ CONTENT๋ก ๋๋ฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ๋ชจ๋ ์ปจํ
์ธ ๋ <div class="se-component"></div>
๋ก ๊ตฌ์ฑ๋์ด ์์ต๋๋ค.
-
HEADER
- ์นดํ
๊ณ ๋ฆฌ๋ช
: se-component & se-documentTitle > se-component-content > ... > blog2_series
- ์ ๋ชฉ : se-component se-documentTitle > se-component-content > ... > se-title-text
-
CONTENT
-
ํ
์คํธ ์ปดํฌ๋ํธ(se-component & se-text)
-
์ผ๋ฐ ํ
์คํธ : se-component & se-text > se-component-content > se-section-text > se-module-text > p.se-text-paragraph & span
-
๊ณต๋ฐฑ ํ
์คํธ : se-component & se-text > se-component-content > se-section-text > se-module-text > p.se-text-paragraph & span (nothing)
-
๋งํฌ ํ
์คํธ : se-component & se-text > se-component-content > se-section-text > se-module-text > p.se-text-paragraph & se-link
-
ํด์ํ๊ทธ ํ
์คํธ : se-component & se-text > se-component-content > ... > se-module-text > se-text-paragraph > __se-hash-tag
-
์์ ๋ชฉ ์ปดํฌ๋ํธ(se-component & se-sectionTitle)
- ์์ ๋ชฉ ํ
์คํธ : se-component & se-sectionTitle > se-component-content > ... > se-module-text > se-text-paragraph
-
์ธ์ฉ๊ตฌ ์ปดํฌ๋ํธ(se-component & se-quotation)
- ์ธ์ฉ๊ตฌ ํ
์คํธ : se-component & se-quotation > se-component-content > ... > se-module-text > se-text-paragraph
-
๊ตฌ๋ถ์ ์ปดํฌ๋ํธ(se-component & se-horizontalLine)
- ๊ตฌ๋ถ์ : se-component & se-horizontalLine > se-component-content > se-section-horizontalLine > se-module-horizontalLIne > ... > hr.se-hr (์คํ์ผ์ ๋ฐ๋ผ ๋ณํ์ง๋ ์์)
-
์ผ์ ์ปดํฌ๋ํธ(se-component & se-schedule) โป ์ง์ํ์ง ์์
- ์ผ์ ํ
์คํธ : se-component & se-schedule > se-component-content > se-section-schedule > se-module-schedule > ... > p.se-schedule-title
- ์ผ์ ๋ฐ์ดํธ : se-component & se-schedule > script[data-module] > data.startAt, data.endAt
-
์ฝ๋ ์ปดํฌ๋ํธ(se-component & se-code)
- ์์ค ์ฝ๋ : se-component & se-code > se-component-content > se-section-code > se-section-code > se-module-code > se-code-source
-
๋ผ์ด๋ธ๋ฌ๋ฆฌ(์ฑ
, ์ํ) ์ปดํฌ๋ํธ(se-component & se-material)
- ๋งํฌ ๋ฐ์ดํฐ : se-component & se-material > se-component-content > se-section-material > a[data-linkdata]
-
์ด๋ฏธ์ง ์ปดํฌ๋ํธ(se-component & se-image)
- ์ด๋ฏธ์ง ์์ค : se-component & se-image > se-component-content > se-section-image > se-module-image > a[data-link, src] or a > img[data-lazy-src]
- ์ด๋ฏธ์ง ํ
์คํธ : se-component & se-image > se-component-content > se-section-image > se-module-text & se-caption > p.se-text-paragraph > span
-
์คํฐ์ปค ์ปดํฌ๋ํธ(se-component & se-sticker)
- ์ด๋ฏธ์ง ์์ค : se-component & se-sticker > se-component-content > se-section-sticker > se-module-sticker > a > img.se-sticker-image[src]
- ์ด๋ฏธ์ง ํ
์คํธ : se-component & se-sticker > se-component-content > se-section-sticker > se-module-text & se-caption > p.se-text-paragraph > span
-
๋น๋์ค ์ปดํฌ๋ํธ(se-component & se-video)
-
ํ์ผ ์ปดํฌ๋ํธ(se-component & se-file)
- ํ์ผ ๋ฐ์ดํฐ : se-component & se-file > se-component-content > se-section-file > se-module-file > a[data-link]
- link๋ก api ์์ฒญ
-
์ง๋ ์ปดํฌ๋ํธ(se-component & se-placeMap) โป ์ง์ํ์ง ์์
- ์ง๋ ๋ฐ์ดํฐ : se-component & se-placeMap > se-component-content > se-section-placeMap > se-module-text > a.se-map-info > se-map-title & se-map-address
-
์๋ฒ ๋๋ ์ปดํฌ๋ํธ(se-component se-oembed)
- ๋น๋์ค ๋ฐ์ดํฐ : ... > content['data-module']
- ๋น๋์ค URL
- ๋น๋์ค ์ ๋ชฉ
- ๋น๋์ค ์ธ๋ค์ผ URL
- ๋น๋์ค description