Skip to content

Instantly share code, notes, and snippets.

import requests
from bs4 import BeautifulSoup
import base64
payload = {}
res = requests.get('http://www.twse.com.tw/ch/trading/exchange/BWIBBU/BWIBBU_d.php')
res.encoding = 'big5'
soup = BeautifulSoup(res.text)
for input_tag in soup.select('input'):
if input_tag.get('type') == 'hidden':
payload[input_tag.get('name')] = base64.b64encode(input_tag.get('value').encode('utf-8'))
@shihyu
shihyu / twse.py
Created April 26, 2016 14:27 — forked from flyakite/twse.py
import BeautifulSoup, requests
r=requests.post('http://www.twse.com.tw/ch/trading/exchange/BWIBBU/BWIBBU.php', {'STK_NO':2330, 'myear': 2016, 'mmon':2})
soup = BeautifulSoup.BeautifulSoup(r.content)
table = soup.find('table', {'class':'board_trad'})
with open('out2.csv', 'w') as f:
trs = table.findAll('tr')
for tr in trs:
@shihyu
shihyu / mp_crawler.py
Created August 4, 2016 19:27 — forked from laing20333/mp_crawler.py
Multi-Processes Crawler (in python 2.x version)
# coding=utf-8
# Goal: parse house information for each district from websites
# for each district, get 「土地區段位置或建物區門牌」,「建物型態」,「建物現況格局」,「坪數」,「屋齡」,「總價元」,「資料來源」into csv file
# Procedure:
# 1. get the number of page for each district by parsing first html content
# 2. for each district put all html page together, use htmlparser to parse content and save data into file
import sys
import math
@shihyu
shihyu / sp_crawler.py
Created August 4, 2016 19:28 — forked from laing20333/sp_crawler.py
Single process Crawler (in python 2.x version)
# coding=utf-8
# Goal:
# parse different city's website
# for each city, get 「土地區段位置或建物區門牌」,「建物型態」,「建物現況格局」,「坪數」,「屋齡」,「總價元」,「資料來源」into csv file
# step:
# 1. get number of page by parsing string
# 2. put all html page together, use htmlparser to get content
# 3. parsing content and save it
@shihyu
shihyu / gps.java
Created August 13, 2016 16:16 — forked from javisantana/gps.java
real/fake gps
package hardware;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.location.LocationProvider;
import gdb
import string
class test_gdb_python_command(gdb.Command):
"test help"
def __init__(self):
super(test_gdb_python_command,self).__init__("test_gdb_python_command",gdb.COMMAND_USER)
import gdb
import string
class test_gdb_python_command(gdb.Command):
"test help"
def __init__(self):
super(test_gdb_python_command,self).__init__("test_gdb_python_command",gdb.COMMAND_USER)
@shihyu
shihyu / compiler.md
Created October 2, 2016 11:24 — forked from JeOam/compiler.md
自制编程语言
@shihyu
shihyu / hello.s
Created October 5, 2016 18:04 — forked from kohyama/hello.s
'Hello World' in MacOS X with 'as' and 'ld'
# Usage:
# Save this file as 'hello.s'.
# $ as -o hello.o hello.s
# $ ld -o hello hello.o
# $ ./hello
#
# How to call a system call
# 1) Set rax to the index of the system call.
# 2) Set rdi, rsi, rdx, ... to arguments in this order.
# 3) Call 'syscall'.
#include "Quaternion.h"
#include <cmath>
// http://content.gpwiki.org/index.php/OpenGL:Tutorials:Using_Quaternions_to_represent_rotation
// http://www.flipcode.com/documents/matrfaq.html
// http://db-in.com/blog/2011/04/cameras-on-opengl-es-2-x/
// http://wiki.beyondunreal.com/Legacy:Quaternion
// http://clb.demon.fi/MathGeoLib/docs/float3x3.cpp_code.html#612
// http://clb.demon.fi/MathGeoLib/docs/Quat_summary.php
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm