Skip to content

Instantly share code, notes, and snippets.

@devjoe
devjoe / crawler_for_taichung.py
Created September 15, 2016 13:02
範例程式碼:從蟒蛇到神龍 - 從 1 接關繼續打造爬蟲程式 @ 台中拍聚會
# -*- coding: utf-8 -*-
target_url = "https://www.khanacademy.org/"
# -------------------------------------------------------
import whois
#print whois.whois(target_url)
@devjoe
devjoe / demo_5.py
Created October 2, 2013 00:09
Tainan.py 2013.09.28
from webtest import TestApp
import demo_2
def test_index():
app = TestApp(demo_2.app)
assert app.get("/").text == u"Hello world @ MOSUT x Tainan.py"
@devjoe
devjoe / demo_4.py
Created October 2, 2013 00:08
Tainan.py 2013.09.28
from pyquery import PyQuery as pq
#d = pq("<html></html>")
#d = pq(filename=path_to_html_file)
d = pq(url='http://www.csie.ncku.edu.tw/new/nckucsie/')
import pdb; pdb.set_trace();
pass
@devjoe
devjoe / demo_3.py
Created October 2, 2013 00:07
Tainan.py 2013.09.28
import requests
r = requests.get("https://google.com.tw")
import pdb; pdb.set_trace();
pass
@devjoe
devjoe / demo_2.py
Created October 2, 2013 00:03
Tainan.py 2013.09.28
from bottle import Bottle, run
app = Bottle()
@app.route('/')
def index():
return "Hello world @ MOSUT x Tainan.py"
if __name__ == "__main__":
run(app, host="localhost", port=8000)
@devjoe
devjoe / demo_1.py
Last active December 24, 2015 10:49
Tainan.py 2013.09.28
# From Thinker: http://pastebin.com/yzy0TjRn
import BaseHTTPServer
class handler(BaseHTTPServer.BaseHTTPRequestHandler): pass
handler.do_GET = lambda x: x.wfile.write('\nHello world @ Tainan.py x MOSUT')
BaseHTTPServer.HTTPServer(('', 8000), handler).serve_forever()