pyquery的html()方法为什么感觉跟text()是也一样
2018-08-12 本文已影响35人
markDownMan
html()方法是获取标签内的包括里面的标签的文本,包括标签
text()方法是获取标签内所有的里面的文本,不包括标签
运行结果:
from pyqueryimport PyQueryas py
doc= py('https://www.23us.so/xiaoshuo/22928.html', encoding="utf-8")
novel_main_link= doc('.btnlinks a.read')
print("novel_main_link:", novel_main_link.attr('href'))
tds= doc.find('td')
print("tds:", tds.eq(1).text())
print("tds:", tds.eq(1).html())
print("tds:", tds.eq(1))
print("tds:", doc.find('td').html())
print("tds:", doc.find('td').text())
print("tds:", doc('td').html())
print("tds:", doc('td').text())