Recently, I've been experimenting with Selenium WebDriver (Chrome) in an attempt to load a page and extract disqus comment threads. Below is the code snippet I used:
public static void Main(string[] args)
{
var driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://nation.com.pk/blogs/05-Apr-2016/should-qandeel-baloch-s-strip-tease-really-be-a-rallying-cause-for-liberalism");
var userNameField = driver.FindElementById("disqus_thread").GetAttribute("outerHTML");
Console.WriteLine(userNameField);
Console.Read();
}
The output generated was as follows:
<div id="disqus_thread"><iframe id="dsq-app2" name="dsq-app2" allowtransparency="true" frameborder="0" scrolling="no" tabindex="0" title="Disqus" width="100%" src="http://disqus.com/embed/comments/?base=default&version=af1a2e2611136ef6c314afec2806cef3&f=nawaiwaqt&t_u=http%3A%2F%2Fnation.com.pk%2Fblogs%2F05-Apr-2016%2Fshould-qandeel-baloch-s-strip-tease-really-be-a-rallying-cause-for-liberalism&t_d=Should%20Qandeel%20Baloch%E2%80%99s%20%E2%80%98striptease%E2%80%99%20really%20be%20a%20rallying%20cause%20for%20liberalism%3F&t_t=Should%20Qandeel%20Baloch%E2%80%99s%20%E2%80%98striptease%E2%80%99%20really%20be%20a%20rallying%20cause%20for%20liberalism%3F&s_o=default" style="width: 1px !important; min-width: 100% !important; border: none !important; overflow: hidden !important; height: 652px !important;" horizontalscrolling="no" verticalscrolling="no"></iframe></div>
This result came as a surprise to me since I had expected to retrieve the comments html instead. Any suggestions on how to tweak this code to obtain the comment thread? PS: There is no mention of iframe in the original page source.