Lxml 或 Xpath 内容打印
我有以下函数
def parseTitle(self, post):
"""
Returns title string with spaces replaced by dots
""
return post.xpath('h2')[0].text.replace('.', ' ')
来查看 post
的内容。我已经尝试了我能想到的一切。
如何正确调试内容?这是一个电影网站,我在其中提取链接和标题,并且此函数应该解析标题。
我确信 H@ 不存在,我该如何打印/调试它?
I have the following function
def parseTitle(self, post):
"""
Returns title string with spaces replaced by dots
""
return post.xpath('h2')[0].text.replace('.', ' ')
I would to see the content of post
. I have tried everything I can think of.
How can I properly debug the content? This is an website of movies where I'm rip links and title and this function should parse the title.
I am sure H@ is not existing, how can I print/debug this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
post
是lxml元素树对象,不是吗?所以首先,您可以尝试:
如果不是,您应该从中创建元素树对象
,或者问题可能只是您应该将
h2
替换为//h2
?你的问题不是很解释..
post
is lxml element tree object, isn't it?so first, you could try:
if isn't, you should create element tree object from it
or maybe the problem is just that you should replace
h2
with//h2
?your question is not very explanatory..