diff --git a/README.md b/README.md index 5a9092a..15625cc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ -# Git Sample +# CashCow -[![Build Status](https://travis-ci.org/dal-lab/git-sample.svg?branch=master)](https://travis-ci.org/dal-lab/git-sample) -[![works badge](https://cdn.jsdelivr.net/gh/nikku/works-on-my-machine@v0.2.0/badge.svg)](https://github.com/nikku/works-on-my-machine) +## 실행하기 -This repository is a playground to learn Git. +``` +python parser.py +``` \ No newline at end of file diff --git a/app.py b/app.py deleted file mode 100644 index df1dc68..0000000 --- a/app.py +++ /dev/null @@ -1 +0,0 @@ -print('Hello World') diff --git a/parser.py b/parser.py new file mode 100644 index 0000000..9c40e45 --- /dev/null +++ b/parser.py @@ -0,0 +1,31 @@ +## parser.py +import requests +from bs4 import BeautifulSoup +import json +import os + +## python파일의 위치 +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) + +req = requests.get('https://beomi.github.io/beomi.github.io_old/') +html = req.text +soup = BeautifulSoup(html, 'html.parser') +my_titles = soup.select( + 'h3 > a' + ) + +# ## my_titles는 list 객체 +# for title in my_titles: +# ## Tag안의 텍스트 +# print(title.text) +# ## Tag의 속성을 가져오기(ex: href속성) +# print(title.get('href')) + +data = {} + +for title in my_titles: + data[title.text] = title.get('href') + +with open(os.path.join(BASE_DIR, 'result.json'), 'w+') as json_file: + json.dump(data, json_file) + diff --git a/result.json b/result.json new file mode 100644 index 0000000..5ac9ae4 --- /dev/null +++ b/result.json @@ -0,0 +1 @@ +{"\ub098\ub9cc\uc758 \uc6f9 \ud06c\ub864\ub7ec \ub9cc\ub4e4\uae30(4): Django\ub85c \ud06c\ub864\ub9c1\ud55c \ub370\uc774\ud130 \uc800\uc7a5\ud558\uae30": "/beomi.github.io_old/python/2017/02/28/HowToMakeWebCrawler-Save-with-Django.html", "\ub098\ub9cc\uc758 \uc6f9 \ud06c\ub864\ub7ec \ub9cc\ub4e4\uae30(3): Selenium\uc73c\ub85c \ubb34\uc801 \ud06c\ub864\ub7ec \ub9cc\ub4e4\uae30": "/beomi.github.io_old/python/2017/02/27/HowToMakeWebCrawler-With-Selenium.html", "Django\uc5d0 Social Login \ubd99\uc774\uae30: Django\uc138\ud305\ubd80\ud130 Facebook/Google \uac1c\ubc1c \uc124\uc815\uae4c\uc9c0": "/beomi.github.io_old/python/2017/02/08/Setup-SocialAuth-for-Django.html", "Django\uc5d0 Custom\uc778\uc99d \ubd99\uc774\uae30": "/beomi.github.io_old/python/2017/02/01/Django-CustomAuth.html", "\ub098\ub9cc\uc758 \uc6f9 \ud06c\ub864\ub7ec \ub9cc\ub4e4\uae30(2): Login with Session": "/beomi.github.io_old/python/2017/01/20/HowToMakeWebCrawler-With-Login.html", "\ub098\ub9cc\uc758 \uc6f9 \ud06c\ub864\ub7ec \ub9cc\ub4e4\uae30 with Requests/BeautifulSoup": "/beomi.github.io_old/python/2017/01/19/HowToMakeWebCrawler.html", "Celery\ub85c TelegramBot \uc54c\ub9bc \ubcf4\ub0b4\uae30": "/beomi.github.io_old/2016/12/27/TelegramBot-with-Celery.html", "Virtualenv/VirtualenvWrapper OS\ubcc4 \uc124\uce58&\uc774\uc6a9\ubc95": "/beomi.github.io_old/2016/12/27/HowToSetup-Virtualenv-VirtualenvWrapper.html", "[DjangoTDDStudy] #02: UnitTest \uc774\uc6a9\ud574 \uae30\ub2a5 \ud14c\uc2a4\ud2b8 \ud558\uae30": "/beomi.github.io_old/djangotddstudy/2016/12/26/Django-TDD-Study-02-Using-UnitTest.html", "[DjangoTDDStudy] #01: \uac1c\ubc1c\ud658\uacbd \uc138\ud305\ud558\uae30(Selenium / ChromeDriver)": "/beomi.github.io_old/djangotddstudy/2016/12/26/Django-TDD-Study-01-Setting-DevEnviron.html", "[DjangoTDDStudy] #00: \uc2a4\ud130\ub514\ub97c \uc2dc\uc791\ud558\uba70": "/beomi.github.io_old/djangotddstudy/2016/12/26/Django-TDD-Study-00-Starting-Study.html", "Fabric Put \ucee4\ub9e8\ub4dc\uac00 No Such File Exception\uc744 \ubc18\ud658\ud560 \ub54c \ud574\uacb0\ubc95": "/beomi.github.io_old/2016/12/21/Fabric-Put-Command-No-Such-File-Exception.html", "CKEditor\uc758 \ub77c\uc774\uc13c\uc2a4\uc640 \uc624\ud508\uc18c\uc2a4 \ub77c\uc774\uc13c\uc2a4": "/beomi.github.io_old/2016/12/21/CKEditor-Lisence-and-Pricing.html", "ReactNative The Basis \ubc88\uc5ed\uc744 \ub05d\ub0c8\uc2b5\ub2c8\ub2e4.": "/beomi.github.io_old/translation/2016/12/20/ReactNative-Translation-Intro-Finish.html", "[React Native \ubc88\uc5ed]#01: \uc2dc\uc791\ud558\uae30": "/beomi.github.io_old/translation/2016/11/15/ReactNative-Translation-01-getting-started.html", "[\ubc88\uc5ed] \uc7a5\uace0(Django)\uc640 \ud568\uaed8\ud558\ub294 Celery \uccab\uac78\uc74c": "/beomi.github.io_old/django-celery/programming/python/translation/2016/11/04/eb-b2-88-ec-97-ad-ec-9e-a5-ea-b3-a0django-ec-99-80-ed-95-a8-ea-bb-98-ed-95-98-eb-8a-94-celery-ec-b2-ab-ea-b1-b8-ec-9d-8c.html", "Chrome Native Adblockr \ub300\uccb4\ud558\uae30": "/beomi.github.io_old/tech/2016/09/14/chrome-native-adblockr-eb-8c-80-ec-b2-b4-ed-95-98-ea-b8-b0.html", "CustoMac \uc124\uce58 \ubd84\ud22c\uae30": "/beomi.github.io_old/dev%20env%20setup/mac%20/%20os%20x/tech/2016/08/09/customac-ec-84-a4-ec-b9-98-eb-b6-84-ed-88-ac-ea-b8-b0.html", "Ubuntu14.04\uc5d0 OhMyZsh \uc124\uce58": "/beomi.github.io_old/dev%20env%20setup/tech/ubuntu%20/%20debian/2016/07/22/ubuntu14-04-ec-97-90-ohmyzsh-ec-84-a4-ec-b9-98.html", "Ubuntu14.04\uc5d0\uc11c pip\ub85c mysqlclient \uc124\uce58 \uc2e4\ud328\uc2dc": "/beomi.github.io_old/programming/python/tech/2016/07/22/ubuntu14-04-ec-97-90-ec-84-9c-pip-eb-a1-9c-mysqlclient-ec-84-a4-ec-b9-98-ec-8b-a4-ed-8c-a8-ec-8b-9c.html", "Ubuntu14.04\uc5d0\uc11c Python3\uae30\ubc18 virtualenvwrapper \uc124\uce58": "/beomi.github.io_old/mac%20/%20os%20x/programming/python/tech/2016/07/22/ubuntu14-04-ec-97-90-ec-84-9c-python3-ea-b8-b0-eb-b0-98-virtualenvwrapper-ec-84-a4-ec-b9-98.html", "mac OS X\uc5d0\uc11c pip virtualenvwrapper \uc124\uce58 \uc2dc uninstalling six \uc5d0\uc11c Exception \ubc1c\uc0dd \uc2dc": "/beomi.github.io_old/mac%20/%20os%20x/programming/python/tech/2016/07/21/mac-os-x-ec-97-90-ec-84-9c-pip-virtualenvwrapper-ec-84-a4-ec-b9-98-ec-8b-9c-uninstalling-six-ec-97-90-ec-84-9c-exception-eb-b0-9c-ec-83-9d-ec-8b-9c.html", "Fabric for Python3 (Fabric3)": "/beomi.github.io_old/programming/python/2016/07/17/fabric-for-python3-fabric3.html", "Windows\uc5d0\uc11c pip\ub85c mysqlclient \uc124\uce58 \uc2e4\ud328\uc2dc(python3.4/3.5)": "/beomi.github.io_old/programming/python/2016/06/04/windows-ec-97-90-ec-84-9c-pip-eb-a1-9c-mysqlclient-ec-84-a4-ec-b9-98-ec-8b-a4-ed-8c-a8-ec-8b-9cpython3-43-5.html", "\ub9e5\uc5d0\uc11c \uc708\ub3c4RDP\ub85c \uc811\uc18d\uc2dc \ud55c\uc601\uc804\ud658\ud558\uae30.": "/beomi.github.io_old/mac%20/%20os%20x/tech/2016/05/27/eb-a7-a5-ec-97-90-ec-84-9c-ec-9c-88-eb-8f-84rdp-eb-a1-9c-ec-a0-91-ec-86-8d-ec-8b-9c-ed-95-9c-ec-98-81-ec-a0-84-ed-99-98-ed-95-98-ea-b8-b0.html", "pip\ub85c mysqlclient\uc124\uce58 \uc911 mac os x\uc5d0\uc11c egg_info / OSError \ubc1c\uc0dd\uc2dc \ub300\ucc98\ubc29\ubc95": "/beomi.github.io_old/programming/python/2016/05/27/pip-eb-a1-9c-mysqlclient-ec-84-a4-ec-b9-98-ec-a4-91-mac-os-x-ec-97-90-ec-84-9c-egg_info-oserror-eb-b0-9c-ec-83-9d-ec-8b-9c-eb-8c-80-ec-b2-98-eb-b0-a9-eb-b2-95.html"} \ No newline at end of file diff --git a/text_formatter.py b/text_formatter.py deleted file mode 100644 index 1658c8d..0000000 --- a/text_formatter.py +++ /dev/null @@ -1,35 +0,0 @@ -""" -주어진 format에 맞춰 문자열을 생성하는 함수를 생성 -""" - - -def string_maker(length=0, align='LEFT', padding=''): - """ - param으로 받은 length, align, padding으로 문자열 format을 설정 - """ - ALIGN_SIGN = { - 'LEFT': '', - 'RIGHT': '>', - 'MID': '^', - } - - def wrapper(data): - return "{:{padding}{align}{len}}".format( - data[:length], - padding=padding, - align=ALIGN_SIGN.get(align), - len=length) - return wrapper - - -if __name__ == '__main__': - data_sample = { - 'NAME': 'ABC', - 'NICK': 'DUCK', - } - - name = string_maker(length=13) - nick = string_maker(length=20, align='MID', padding='*') - layout = [name(data_sample.get('NAME')), nick(data_sample.get('NICK'))] - - print(''.join([f'{item}' for item in layout])) diff --git a/text_formatter_test.py b/text_formatter_test.py deleted file mode 100644 index 609cadc..0000000 --- a/text_formatter_test.py +++ /dev/null @@ -1,51 +0,0 @@ -""" -string_maker test -""" - - -import pytest -import text_formatter - - -def test_string_maker_length(): - length = 10 - text_length_10 = text_formatter.string_maker(length=length) - assert len(text_length_10('12345')) == length - - -def test_string_maker_length_over(): - length = 10 - text_length_10 = text_formatter.string_maker(length=length) - assert len(text_length_10('1234567890123')) == length - - -def test_string_maker_align_left(): - test_word = 'AAAAA' - length = 20 - text_align_left = text_formatter.string_maker(length=length) - assert text_align_left(test_word) == test_word.ljust(length, ' ') - - -def test_string_maker_align_right(): - test_word = 'AAAAA' - length = 20 - text_align_right = text_formatter.string_maker( - length=length, align='RIGHT') - assert text_align_right(test_word) == test_word.rjust(length, ' ') - - -def test_string_maker_align_center(): - test_word = 'AAAAA' - length = 20 - text_align_center = text_formatter.string_maker(length=length, align='MID') - assert text_align_center(test_word) == test_word.center(length, ' ') - - -def test_string_maker_align_center_padding_star(): - test_word = 'AAAAA' - length = 20 - padding = '*' - text_align_center_padding_star = text_formatter.string_maker( - length=length, align='MID', padding=padding) - assert text_align_center_padding_star(test_word) \ - == test_word.center(length, padding)