編碼1:測試 中文對應的網頁實體編碼unicode
編碼2:\u6d4b\u8bd5
編碼3:測試 中文對應的網頁實體編碼utf-8
編碼4:\xe6\xb5\x8b\xe8\xaf\x95
編碼4:ascii 碼,其中三個\x表示乙個漢字
s=b'\xe6\xb5\x8b\xe8\xaf\x95'
>>> print(s.decode('utf-8'))
測試》 a='\xe6\xb5\x8b\xe8\xaf\x95'
>>> a
'\xe6\xb5\x8b\xe8\xaf\x95'
>>> a.decode('utf-8')
u'\u6d4b\u8bd5'
>>> print a.decode('utf-8')測試
編碼1 和3 是html實體,可以通過標準庫htmlparser 來解析:
Python抓取中文網頁
早就有想法把部落格每天的訪問流量記下來,剛好現在申請了gae的應用,又開始學python,正好拿這個練手。打算先利用python把訪問記錄儲存在本地,熟悉之後可以部署到gae,利用gae提供的cron就可以每天更近訪問流量了。ok,開始 首先是簡單的網頁抓取程式 python view plain ...
BeautifulSoup 解析中文網頁亂碼問題
import urllib2 from beautifulsoup import beautifulsoup page urllib2.urlopen soup beautifulsoup page,fromencoding gb18030 print soup.originalencoding p...
挖掘 UltraEdit 優化中文網頁功能
揭開html tidy的面紗,網頁優化功能是ultraedit8.x版本的 format 選單中的 html tidy 命令提供的。html tidy是ultraedit整合的第三方軟體,ultraedit在幫助檔案中特別提示,html tidy提供了大量配置選項,可以在配置檔案中設定,具體設定方法...