Tag: 兄弟

XPath ::获取以下兄弟

我有以下的HTML结构:我想build立一个强大的方法来提取第二个颜色摘要元素,因为在DOM中会有很多这些标记。 <table> <tbody> <tr bgcolor="#AAAAAA"> <tr> <tr> <tr> <tr> <td>Color Digest </td> <td>AgArAQICGQMVBBwTIRQHIwg0GUMURAZTBWQJcwV0AoEDAQ </td> </tr> <tr> <td>Color Digest </td> <td>2,43,2,25,21,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,33,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,25,0,0,0,0,0,0,0,0,0,0,0,0,0,0,20,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, </td> </tr> </tbody> </table> 我正试图提取具有解码值的第二个“Color Digest”td元素。 我写了下面的xpath,而不是得到第二我没有得到第二个TD元素。 //td[text() = ' Color Digest ']/following-sibling::td[2] 而当我把它改为td [2]到td [1]时,我得到了两个元素。

兄弟姐妹包import

我已经尝试阅读兄弟import甚至包文档的问题 ,但我还没有find答案。 具有以下结构: ├── LICENSE.md ├── README.md ├── api │ ├── __init__.py │ ├── api.py │ └── api_key.py ├── examples │ ├── __init__.py │ ├── example_one.py │ └── example_two.py └── tests │ ├── __init__.py │ └── test_one.py examples和tests目录中的脚本如何从api模块导入并从命令行运行? 此外,我想避免每个文件的丑陋sys.path.insert hack。 这当然可以在Python中完成,对吗?