https://confluence.atlassian.com/bitbucketserver/basic-git-commands-776639767.html
2015年12月2日 星期三
2015年10月28日 星期三
[python] BeautifulSoup 出現亂碼
http://stackoverflow.com/questions/7219361/python-and-beautifulsoup-encoding-issues
url = "http://ocg.xpg.jp/search/search.fcgi?CardNo=1Record=1"
res = requests.get(url, verify=False)
content = res.content
soup = BeautifulSoup(content.decode('Shift_JIS','ignore'))
titlename = soup.find('title').string
print titlename
[python] python爬網頁資料
工具:
requests: http://docs.python-requests.org/en/latest/
送出http請求
BeautifulSoup: http://www.crummy.com/software/BeautifulSoup/bs4/doc/
分析抓回來的html原始碼
範例:
import requests
from BeautifulSoup import BeautifulSoup
url = "http://ocg.xpg.jp/search/search.fcgi?CardNo=1&Record=1"
res = requests.get(url, verify=False)
soup = BeautifulSoup(''.join(res))
titlename = soup.find('title').string
table1 = soup.find(class_="Hover w9")
for row in table1.findAll('tr'):
col = table1.findAll('td')
day = col[0].string
cheap = col[2].string
top = col[3].string
print titlename
[python] python連結mysql資料庫
模組:MySQLdb
官網:http://sourceforge.net/projects/mysql-python/
安裝:pip install MySQL-python
用法:
http://drizzlewalk.blog.51cto.com/2203401/448874
範例:
db = MySQLdb.connect(host="localhost", user="root", passwd="12345678", db="yugioh")
db.set_character_set('utf8')
cursor = db.cursor()
sqlcommand = "INSERT INTO `yugioh`.`yugioh` (`number`, `name`, `day`, `cheap`, `top`) VALUES ('aa', 'bb', 'cc', 'dd', 'ee')"
cursor.execute(sqlcommand)
db.commit()
2015年10月21日 星期三
[python] UnicodeDecoderError 編碼錯誤
其實這問題好像在windows的cmd上執行python比較會遇到
同一個code在mac上沒問題,跑在windows的cmd上就出錯 XD
解法:
http://www.crifan.com/unicodeencodeerror_gbk_codec_can_not_encode_character_in_position_illegal_multibyte_sequence/comment-page-1/
訂閱:
文章 (Atom)