python爬虫报错:AttributeError: ‘NoneType‘ object has no attribute ‘xpath‘

今天学了一下python爬虫,遇到一个报错:AttributeError: 'NoneType' object has no attribute 'xpath',试了一下网上说的修改路径,不成功,差不多快要绝望的时候,从头到尾检查一遍代码才发现我在写请求头的时候把

User-Agent

写成了

User_Agent

真是不该的低级错误,而且Pycharm没有把问题行定位正确,只是定到了“xpath”这一行,其他的没有报错。