Skip to content

Instantly share code, notes, and snippets.

View ywchiu's full-sized avatar

David Chiu ywchiu

View GitHub Profile
# -*- coding: utf-8 -*-
from selenium import selenium
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
from bs4 import BeautifulSoup
browser = webdriver.Firefox()
import requests
from bs4 import BeautifulSoup as bs
res = requests.get('https://tw.bid.yahoo.com/tw/show/auctions?userID=Y6216276935&u=%3AY6216276935&clf=1#bd')
soup = bs(res.text)
for ele in soup.select('#yaubhil li'):
print ele.select('a')[0]['href'] , ele.select('a img')[0]['title'], ele.select('a img')[0]['src']
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
res = requests.get('http://www.tdcc.com.tw/smWeb/QryStock.jsp?SCA_DATE=20150724&SqlMethod=StockNo&StockNo=2330&StockName=&sub=%ACd%B8%DF')
soup = BeautifulSoup(res.text)
stock = []
table = soup.select('.mt')[1]
for ele in table.select('tr')[1:]:
td = ele.select('td')
print td[0].text.encode('utf-8'), td[1].text.encode('utf-8') td[2].text.encode('utf-8'), \
import requests
from bs4 import BeautifulSoup
res = requests.get('http://tw.taobao.com/product/%E5%A4%9A%E6%A8%A3%E5%B1%8B-%E8%91%AB%E8%98%86-%E4%BF%9D%E6%BA%AB%E6%9D%AF.htm')
soup = BeautifulSoup(res.text)
for item in soup.select('.item'):
print item.select('strong')[0].text
import requests
import re
res = requests.get('http://odds.zso8.com/html/match.html?t=20150624225319')
res.encoding = 'utf-8'
m = re.findall('m\[\d+\]=\"(.*?)\".split\(\',\'\);', res.text)
for ele in m:
print ele.split(',')[9]
import requests
header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.81 Safari/537.36',
'Cookie':'ASP.NET_SessionId=vkwwsfz4wjg3ej2o24mvac55; _ga=GA1.3.1009046832.1433175011; _gat=1; JubFrm-pagebox=%5EcourtFullName%3DTPDV%60%5Edy1%3D104%5Edm1%3D1%5Edd1%3D1%5Edy2%3D104%5Edm2%3D6%5Edd2%3D1%5Ejcatagory%3D0%5Eissimple%3D-1; y=p=VOUqAM8JSOHlsY%2byfpFRE3vG5r1FlWQQ%2bOuqDXyVne7gOxzydtBd08ujzgKglcOj; x=j=ExKZIgGGiQD19KUxjSulmQb58Xq9tzxh/6k2CZDMXMbqn+pyISjsF42Gyv8r7WXOK2TSUk8PjqCjFgL8iLOg+rhTDZRS/LF6A3yiOorRKBbqqfvT9nsAos6HffvejAESNTDqD1WguB6T7rQNSzOeq5kex9NSLQZUItrs84CqGL2v06p7VA8mxEwzCTHWAR1K2hgLnuTA4OwNIi895B4ZUOdZk4RVXu3nRwXQ+8uEnsY508rOpEzUh+n3Q72p/Dks3lfSuQ/0YF+ZtIfJegXo0b1HyufYOYRQsLZkW05Racc=',
}
res = requests.get('http://fyjud.lawbank.com.tw/content3.aspx?p=tCqhCVJajSdSvECB24EhgQGmqpHQnLGUaI76sp7fUFw%3d', headers = header)
print res.text
import requests
from bs4 import BeautifulSoup
res = requests.get('http://www.ipeen.com.tw/shop/70978-%E5%8F%B0%E7%81%A3%E9%81%94%E7%BE%8E%E6%A8%82')
soup = BeautifulSoup(res.text)
print soup.select('.info h1')
import requests
from bs4 import BeautifulSoup
res = requests.get('http://www.ipeen.com.tw/shop/70978-%E5%8F%B0%E7%81%A3%E9%81%94%E7%BE%8E%E6%A8%82')
soup = BeautifulSoup(res.text)
print soup.select('h1')[0].text.strip()
ipython profile create default
python -c "from IPython.lib import passwd; print passwd()" > /home/ubuntu/.ipython/profile_default/nbpasswd.txt
vi /home/ubuntu/.ipython/profile_default/ipython_config.py
ipython setting
========================================
c.IPKernelApp.pylab = 'inline'
1,101,5.0
1,102,3.0
1,103,2.5
2,101,2.0
2,102,2.5
2,103,5.0
2,104,2.0
3,101,2.0
3,104,4.0
3,105,4.5