刚开始学网络爬虫,第一个程序,只能打出来hello这是为什么啊


import lxml.html,requests
ur1='https://peps.python.org/pep-0020/#the-zen-of-python'
xpath='//*[@id="the zen of python"]/pre/text()'
res=requests.get(ur1)
ht=lxml.html.fromstring(res.text)
text=ht.xpath(xpath)
print('Hello,\n'+''.join(text))

就是这么打出来的
执行之后只能出个hello

img

img


难道是版本不行嘛,我用的也是python3.10啊

你这个xpath取到的内容本来就是空的,当然打印不出东西