Skip to content

Instantly share code, notes, and snippets.

View neoneo40's full-sized avatar

neo neoneo40

  • Seoul, Korea
View GitHub Profile
@neoneo40
neoneo40 / re_literal_count.py
Created July 10, 2015 03:16
문자의 범위 횟수 설정 문제 in regex
import re
s = '{content:5}'
result = re.search('\{content:([0-9])\}', s)
print(result.group(1))
# 5
@neoneo40
neoneo40 / highlight_pygments.py
Last active August 29, 2015 14:26
How to highlight html file with python
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>
@neoneo40
neoneo40 / commu.py
Last active August 29, 2015 14:27
자바스크립트로 동작하는 버튼이 있을 때 다음 페이지로 가는 방식을 구현한 scrapy spider, 네이버 지식쇼핑 다음페이지 숫자 링크 클릭할 때 동작하는 스크립트
#출처: 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"
@neoneo40
neoneo40 / README.md
Last active September 8, 2015 06:18 — forked from e9t/README.md
식신로드 만점 식단 20선
  • 데이터 출처: http://m.wikitree.co.kr/main/news_view.php?id=217101
  • 데이터 수집: 위 기사에서 crawl.py를 이용해 맛집 목록 수집 후 네이버 지도 API를 이용해서 좌표 정보 수집
  • Author: Lucy Park
  • License: Apache v2
  • 20번째 식당이 출력되지 않는 버그 수정
@neoneo40
neoneo40 / list_sort_reverse.py
Last active September 26, 2015 23:19
python sort, reverse in list
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]
@neoneo40
neoneo40 / strftime_in_python.py
Last active September 27, 2015 00:08
time.time() to strftime in python. %I, %p, %H. http://strftime.org/
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')
@neoneo40
neoneo40 / Combinate_user_pass_in_python.md
Last active October 7, 2015 00:22
Combinae user, pass in python

list로 있을 때 조합 구하기

user = ['root', 'manager']
pass_ = ['123',
'456',
'asd',
'password',
'admin']
@neoneo40
neoneo40 / requests_get.py
Created October 19, 2015 11:00
requests.get
# -*- coding: utf-8 -*-
import requests
url = 'http://www.lezhin.com/'
resp = requests.get(url)
print(resp.text)
@neoneo40
neoneo40 / file_sig.py
Last active October 26, 2015 11:52
packet analysis
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)))