【问题标题】:Click button using curl使用 curl 单击按钮
【发布时间】:2016-11-17 15:38:08
【问题描述】:

我需要从 URL 中获取联系电话,可能正在使用 curl。

示例链接-https://www.olx.pl/oferta/philips-sluchawki-bezprzewodowe-shc5100-CID99-IDiER3w.html#188a0d656b

右侧的联系人号码按钮和值已隐藏。一旦你点击它,价值就会出现。按钮上没有 onclick 事件。请告诉我。

【问题讨论】:

    标签: linux curl wget


    【解决方案1】:

    您可以结合使用 curl、sed 和 grep 命令输出。

    这是一个例子:

    wget -q -O - $(echo http://www.olx.pl/ajax/misc/contact/phone/$(curl -s  https://www.olx.pl/oferta/philips-sluchawki-bezprzewodowe-shc5100-CID99-IDiER3w.html#188a0d656b | grep link-phone | egrep -oh \'id\'\:\'\\S+\' | tail -n 1 | sed -e s/\'id\'\://g | sed -e s/\'//g))
    

    【讨论】:

    • 不幸的是,这没有产生任何输出。
    • 看起来 grep(颜色)正在添加一些查询字符。这让它失败了。我进一步通过管道输出 curl 以删除这些字符,如curl -s <URL> | grep link-phone | egrep -oh \'id\'\:\'\\S+\' | tail -n 1 | sed -e s/\'id\'\://g | sed -e s/\'//g | perl -pe 's/\x1b.*?[mGKH]//g'。它现在就像一个魅力。谢谢@mariuszs80
    猜你喜欢
    • 2012-06-11
    • 2021-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-12
    • 2016-02-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多