大家好 最近想試著撰寫網頁爬蟲
想抓取網頁的這部分資訊
http://imgur.com/rNdE4hh
嘗試的結果為
# -*- coding: utf-8 -*-
from urllib2 import urlopen
import xml.etree.ElementTree as ET
from lxml import etree
import mechanize
import sys
url = "http://www.tham.com.tw/recipe6.php"
path = "//*[@id=\"left-inner\"]/div[2]/div[3]"
html = urlopen(url).read()
tree = etree.HTML(html)
startindex = 4
data = tree.xpath(path)
print data[0].text
Output:
>>> ================================ RESTART ================================
>>>
材料 2人份
>>>
看網頁的原始碼猜測是因為<br />阻擋了判斷的緣故
請問這個有解嗎??