2017-03-23
問題描述:
#選擇出節點中“時間”二字
<h2>時間</h2>
item["file_urls"]= response.xpath("//h2[text()= '時間']")
#報錯:ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters
解決方法:
(1)s = u'時間'
item["time"]= response.xpath("//h2[text()= '%s']"%(s))
(2)item["time"]= response.xpath(u"//h2[text()= '時間']")