From a856c32be547851704a7307e240e273f852e9f97 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Thu, 22 Jun 2017 10:52:41 +0200 Subject: [PATCH] Add an example of instrumentation to capture the HTML for later analysis --- tests/instument_to_catch_promoted_tweets.diff | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/instument_to_catch_promoted_tweets.diff diff --git a/tests/instument_to_catch_promoted_tweets.diff b/tests/instument_to_catch_promoted_tweets.diff new file mode 100644 index 0000000..3f27dd5 --- /dev/null +++ b/tests/instument_to_catch_promoted_tweets.diff @@ -0,0 +1,20 @@ +diff --git a/src/Tweeper.php b/src/Tweeper.php +index 8ac2fe3..c45aab5 100644 +--- a/src/Tweeper.php ++++ b/src/Tweeper.php +@@ -355,6 +355,15 @@ class Tweeper { + $html = call_user_func_array(array($this, $preprocess_html_host_method), array($html)); + } + ++ // XXX REMOVE: instrumentation to catch promoted tweets ++ if ($host == "twitter.com") { ++ $twitter_promoted_match_expr = '/promoted/i'; ++ $ret = preg_match($twitter_promoted_match_expr, $html, $matches); ++ if ($ret) { ++ file_put_contents("/home/ao2/TWITTER_PROMOTED_DUMP.html", $html); ++ } ++ } ++ + $xmlDoc = $this->htmlToXml($html, $host); + if (NULL === $xmlDoc) { + return NULL; -- 2.1.4