xpath - 使用 \n 和空格查找类名的 xpath
问题描述
这可能是一个简单的问题,我是新手。
我正在尝试获取此 div 中的数据
<div class="search-results-listings
" vocab="http://schema.org/" typeof="SearchResultsPage">
response.xpath("//div[@class='search-results-listings\n']") 和 response.xpath("//div[@class='search-results-listings\n ']") 是返回空数组
解决方案
您可以使用XPath
's contains
:
response.xpath("//div[contains(@class, 'search-results-listings')]")
推荐阅读
- r - 如何在 R 中重命名具有相似名称和代码的变量?
- ansible - 如何从 Ansible 中控制器的主机文件中获取 IP 地址?
- vba - 检查文本表单字段中的重复项
- mysql - 查询连接两列并在每列左侧获取一行,该列的右表数组引用到左表行
- apache-flink - Flink 中所有算子的侧输出?
- python - 如何在python中上传文件时读取内存中zip文件的内容?
- vba - 如何查找文本引用
- c# - 如何使用 PropertyGrid 允许在没有设置器的情况下编辑属性?
- c++ - 包装多种可能类型的 C++ 类的正确设计
- angularjs - AngularJS - NVDA 屏幕阅读器找不到子元素的名称