javascript
  • php
  • 2017-07-16 30 views 1 likes 
    1

    私は電子メールアドレスを収集するためのWebクローラツールを作成しています。 HTMLコンテンツをダウンロードし、DomCrawlerを使用して、それを解析した後、私は、このノードの値を取得する:デコードJavaScriptエンコードされたコンテンツ

    <!-- 
    document.write("<a rel='nofollow' href='mailto:&#104;&#105;&#101;&#117;&#98;&#100;&#115;&#104;&#97;&#112;&#112;&#121;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;'>&#104;&#105;&#101;&#117;&#98;&#100;&#115;&#104;&#97;&#112;&#112;&#121;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;"); 
    //-->This email address has been protected. You need to enable JavaScript to view the content. 
    

    私はそれを解読できますか?

    答えて

    2

    値は元の文字列の文字のhtmlエンコードされた値なので、PHPではhtml_entity_decodeを使用して元のテキストを取得できます。

    $returnValue = html_entity_decode('mailto:&#104;&#105;&#101;&#117;&#98;&#100;&#115;&#104;&#97;&#112;&#112;&#121;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;'>&#104;&#105;&#101;&#117;&#98;&#100;&#115;&#104;&#97;&#112;&#112;&#121;&#64;&#103;&#109;&#97;&#105;&#108;&#46;&#99;&#111;&#109;', ENT_COMPAT); 
    

    参照:https://www.functions-online.com/html_entity_decode.html

    関連する問題