This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
s = '{content:5}' | |
result = re.search('\{content:([0-9])\}', s) | |
print(result.group(1)) | |
# 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jsbeautifier | |
from BeautifulSoup import BeautifulSoup as bs | |
from IPython.display import HTML | |
from pygments import highlight | |
from pygments.lexers import get_lexer_by_name | |
from pygments.formatters.html import HtmlFormatter | |
lexer = get_lexer_by_name('html') | |
# <pygments.lexers.HtmlLexer> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#출처: https://ide.c9.io/redapple/so_18810850 | |
from scrapy.spider import BaseSpider | |
from scrapy.http import Request, FormRequest | |
from scrapy.selector import HtmlXPathSelector | |
from scrapy.contrib.spiders import Rule | |
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor | |
class MySpider(BaseSpider): | |
name = "commu" |
- 데이터 출처: http://m.wikitree.co.kr/main/news_view.php?id=217101
- 데이터 수집: 위 기사에서
crawl.py
를 이용해 맛집 목록 수집 후 네이버 지도 API를 이용해서 좌표 정보 수집 - Author: Lucy Park
- License: Apache v2
- 20번째 식당이 출력되지 않는 버그 수정
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sort(digits, reverse=False): | |
digits.sort() | |
if reverse: | |
digits.reverse() | |
return digits | |
l = [5, 3, 1, 4, 9, 6] | |
print(sort(l)) | |
# [1, 3, 4, 5, 6, 9] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time.time() | |
# 1443311925.874013 | |
datetime.datetime.fromtimestamp(int(time.time())) | |
# datetime.datetime(2015, 9, 27, 8, 58, 40) | |
datetime.datetime.fromtimestamp(int(time.time())).strftime('%Y-%m-%d %H:%M:%S') | |
# '2015-09-27 08:58:57' | |
datetime.datetime.fromtimestamp(int(time.time())).strftime('%Y-%m-%d %I:%M:%S %p') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import requests | |
url = 'http://www.lezhin.com/' | |
resp = requests.get(url) | |
print(resp.text) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import magic | |
with magic.Magic() as m: | |
path = '/Users/re4lfl0w/Documents/_tmp/2/' | |
for ele in os.listdir(path): | |
ele = os.path.join(path, ele) | |
print('{} - {}'.format(os.path.basename(ele), m.id_filename(ele))) |