본문 바로가기

반응형

엔지니어/Python

(10)
python html 파싱 2 #!-#-coding: utf8-*- import urllib.request from bs4 import BeautifulSoup # 기온데이터를 저장할 파일을 쓰기모드로 연다 f = open('wunder-data-seoul.txt', 'w') # 1월에서 12월까지 각 날짜의 페이지를 순회하면서 기온정보를 뽑아낸다 for m in range(1, 13): for d in range(1, 32): if (m == 2 and d > 28): #2월이 28일을 넘으면 중단하고 다음 달로 넘어간다 break elif (m in [4, 6, 9, 11] and d > 30): #4, 6, 9, 11월이 30일을 넘으면 중단하고 다음 달로 넘어간다 break if (len(str(m)) == 1) and (le..
python 으로 mysql 를 접근할때 python 으로 mysql 를 접근할때 >>> db = MySQLdb.connect(host=dbcon['host'],user=dbcon['user'],passwd=dbcon['passwd'],db=dbcon['db']) Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.4/site-packages/MySQLdb/__init__.py", line 75, in Connect return Connection(*args, **kwargs) File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line 164, in __init__ super(Connecti..
python html 파싱 http://pwnbit.kr/category/Language/Python HTML 파싱할 일이 생겼는데, 그동안은 그냥그냥 필요한 내용만 crummy에서 짬짬히 보다가, BeautifulSoup을 한국말로 잘 정리한 사이트를 찾았다. susukang98님의 블로그 : http://susukang98.springnote.com/pages/333771 예를 들자면, BeautifulSoup을 이용해서 특정 홈피의 내용 중, 어느 부분은 읽는다면 다음과 같이 간단하게 끝낼수 있을 것이다. (사실 정규식을 잘 쓴다면 필요없을 것이다...) from BeautifulSoup import BeautifulSoup import urllib2 url = 'http://블라블라' handle = urllib2.urlo..
Grumpy: Go running Python OverviewGrumpy is a Python to Go source code transcompiler and runtime that is intended to be a near drop in replacement for CPython 2.7. The key difference is that it compiles Python source code to Go source code which is then compiled to native code, rather than to bytecode. This means that Grumpy has no VM. The compiled Go source code is a series of calls to the Grumpy runtime, a Go library s..
parsing import urllib, urllib2, cookielib import re import MySQLdb import time username = 'louie0' password = 'tjrrb12' ##### Parsing data ##### cj = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) login_data = urllib.urlencode({'param_username' : username, 'param_password' : password}) opener.open('http://skjd30g-b.j2.co.kr:28099/cgi-bin/login.cgi', login_data) #res..
python source install 보호되어 있는 글입니다.
Attack alrams 보호되어 있는 글입니다.
pygeoip 1. GeoIP가 지원하는 언어 C LibraryPerl ModulePHP ModuleApache Module (mod_geoip)Java ClassPython ClassC# ClassRuby ModuleMS COM Object?(ASP, ColdFusion, Pascal, PHP, Perl, Python, and Visual Basic code)VB.NET?(Only works with GeoIP Country)PascalJavaScript 2. GeoIP 설치 git clone git://github.com/appliedsec/pygeoip.gitcd pygeoippython setup.py buildsudo python setup.py install 3. GeoIP에 사용될 IP 데이터베이스 다운로..
DDoS Attack alarm(telegram) 보호되어 있는 글입니다.
python 프로세스 죽이기 def killhandle(signum, frame): ''' This will close connections cleanly ''' line = "SIGTERM detected, shutting down" syslog.syslog(syslog.LOG_INFO, line) rdb_server.close() syslog.closelog() sys.exit(0) signal.signal(signal.SIGTERM, killhandle)

반응형