我试图从蜘蛛代码下面的cachdescription
项中替换“CDATA”的文字:
item['CacheDescription']= response.xpath("//html").replace("CDATA" ,' ')
输出:
* <![CDATA[ */ function URLReplacePlus(strIn) { var a = "+"; var b = "%43"; var c = strIn; var i = c.indexOf(a); var l = b.length; while (i != -1) { c = c.substring(0,i) + b + c.substring(i + a.length,c.length);
答案 0 :(得分:2)
您需要调用extract()
来获取实际的字符串值:
response.xpath("//html").extract()[0].replace("CDATA" ,' ')