Skip to content

Instantly share code, notes, and snippets.

View ywchiu's full-sized avatar

David Chiu ywchiu

View GitHub Profile
{"children": [{"children": [{"company_name": "Anko Food Machine Co.,Ltd", "company_type": "supplier", "customs_count": 47, "is_my_trading_partner": false, "iso2": "tw", "params": {"permanent_id": 34169199, "unverified": false}, "profile_url": "https://cn.panjiva.com/Anko-Food-Machine-Co-Ltd/34169199", "unique_id": 1833612}], "company_name": "Anko Food Tech Inc.", "company_type": "buyer", "customs_count": 47, "is_my_trading_partner": false, "iso2": "us", "params": {"permanent_id": 36774586, "unverified": false}, "profile_url": "https://cn.panjiva.com/Anko-Food-Tech-Inc/36774586", "unique_id": 93498319}, {"children": [{"company_name": "Sea Wealth Frozen Food", "company_type": "supplier", "customs_count": 19, "is_my_trading_partner": false, "iso2": "th", "params": {"permanent_id": 28392618, "unverified": false}, "profile_url": "https://cn.panjiva.com/Sea-Wealth-Frozen-Food/28392618", "unique_id": 75572119}, {"company_name": "Anko Food Machine Co.,Ltd", "company_type": "supplier", "customs_count": 17, "is_my_trad
https://bit.ly/2L8r2oA
http://bit.ly/2NgRoCl
import requests
headers = {
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36'
}
res = requests.get('http://www.jiandanxinli.com/experts', headers = headers)
res.text
import requests
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36'
}
res=requests.get('https://tw.stock.yahoo.com/q/q?s=2330', headers = headers)
print res.text
import requests
import pandas
import json
url = 'http://ecshweb.pchome.com.tw/search/v3.3/all/results?q=%E5%88%AE%E9%AC%8D%E5%88%80&page=2&sort=rnk/dc'
r = requests.get(url)
jd = json.loads(r.text)
df = pandas.DataFrame(jd['prods'])
df.head()
from bs4 import BeautifulSoup as bs
html = """
<div class="aaa">
Hello,how are you?
<a>wwww</a>
<strong>yyy</strong>
I'am fine.
</div>
"""
soup = bs(html, 'html5lib')
@ywchiu
ywchiu / 0_reuse_code.js
Created October 11, 2015 05:37
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
import requests
from bs4 import BeautifulSoup as bs
rs = requests.session()
payload = {
'pageTypeHidden':'1',
'code':'1101',
'ctl00$ContentPlaceHolder1$DropDownList1':'2015年6月'
}
res = rs.get('http://www.cnyes.com/twstock/directorholder/1101.htm')
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'))
import requests
import json
import math
n = 963
pages = int(math.ceil(float(n)/10))
for page in range(1, pages+1):
res = requests.get('http://www.agoda.com/api/zh-tw/Main/GetReviewComments?HotelId=908412&travellerTypeId=0&pageSize=10&pageNo={}&sortingOption=1'.format(page))
jd = json.loads(res.text)
for review in json.loads(res.text)['Comments']:
print review['ReviewTitle']