Add an example of instrumentation to capture the HTML for later analysis
authorAntonio Ospite <ao2@ao2.it>
Thu, 22 Jun 2017 08:52:41 +0000 (10:52 +0200)
committerAntonio Ospite <ao2@ao2.it>
Tue, 27 Jun 2017 10:01:37 +0000 (12:01 +0200)
tests/instument_to_catch_promoted_tweets.diff [new file with mode: 0644]

diff --git a/tests/instument_to_catch_promoted_tweets.diff b/tests/instument_to_catch_promoted_tweets.diff
new file mode 100644 (file)
index 0000000..3f27dd5
--- /dev/null
@@ -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;