顯示具有 html 標籤的文章。 顯示所有文章
顯示具有 html 標籤的文章。 顯示所有文章

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

2014年11月24日 星期一

[html] html圖片檔案位置

    網頁檔的位置
    圖檔的位置
    寫法
    說明
    c:\demo
    c:\demo<img src="ex.gif">圖文均在同一目錄
    c:\demo
    c:\demo\image<img src="image/ex.gif">圖在網頁下一層目錄
    c:\demo
    c:\<img src=" ../ex.gif">圖在網頁上一層
    c:\demo
    c:\image<img src=" ../image/ex.gif">圖文在同一層但不同目錄