Htmlagilitypack不会获得节点。

时间:2017-11-21 00:36:43

标签: c# html-agility-pack

我在c#中使用Htmlagilitypack。但是当我想在网址底部的div中选择图像时,选择器中没有任何内容。但我想我写的是正确的选择器。 代码很小。谢谢。

https://dotnetfiddle.net/NNIC3X

app = Flask(__name__)

@app.route("/", methods=['GET', 'POST'])
def camera_toggle():
    from_number = request.values.get('From', None)
    from_message = request.values.get('Body', None)

    resp = MessagingResponse()
    resp.message("Please enter your username:password")
    if ":" not in from_message:
        #Split the username/password, then somehow login??
        return str(resp)
    else:
        from_number = request.values.get('From', None)
        from_message = request.values.get('Body', None)
        if callers[from_number] == "John Doe":
            if from_message == "CameraON":
                subprocess.call(["bash", "camera.sh"])
        return str("Please enter the keyword to turn on the camera")

1 个答案:

答案 0 :(得分:0)

你的xpath是错误的,因为没有div-tag,其class-attribtue值为'col-big'。但是有一个div标签,其class属性的值为'col-big pull-left'。所以试试吧。

            var htmlNodes = doc.DocumentNode.SelectNodes("//div[@class='col-big pull-left']//*/img");
相关问题