0

I am trying to build a c# winforms app (.net 4.0) where i want to comments into the YouTube using webbrowser control. So far i have tried searching similar things on Google and on SO; but i am unable to find a correct tutorial which can guide me through this stuff.

The login stuff was easy, but I am finding it hard to do comments etc. because the site uses jquery/JavaScript.

How to raise click event on divs like that and see the comment box its a div not text. So any pointer on this will be nice. I don't need codes even hints will do. thanks

Alok
  • 808
  • 13
  • 40
  • 1
    The webbrowser control is a requirement that cannot be changed? Because otherwise you might use the official API. – ChrisK Nov 23 '13 at 12:24
  • thats the point i dont want to use the official api, i am creating a bot which will change credential and i want it quick; by the way like problem is already solved. :) – Alok Nov 23 '13 at 14:18
  • humm so whats the best option in this bot case – Alok Nov 23 '13 at 15:26
  • You should be able to traverse the HtmlDocument and call `Invoke` on the desired div. See http://msdn.microsoft.com/en-us/library/system.windows.browser.scriptobject.invoke(v=vs.95).aspx – ChrisK Nov 23 '13 at 15:47
  • ok so here is the thing, ajax loaded comment boxes are not accessible in webbrowser control; any suggestion? – Alok Nov 23 '13 at 17:54
  • I've never tried a webbrowser control with AJAX pages. But this question might help: http://stackoverflow.com/questions/635948/c-sharp-webbrowser-control-get-document-elements-after-ajax – ChrisK Nov 23 '13 at 18:00
  • If the comments are loaded via AJAX, you can just crawl the raw AJAX link (without JS) rather than using a browser control (with JS). – halfer Nov 24 '13 at 00:39
  • halfer can you explain more; how to crawl it without js. @ChrisK thanks for the pointer i tried it and its not working with my issue, any suggestions? – Alok Nov 24 '13 at 05:45
  • hey @halfer at your suggestion i tried this http://pratibha02pandey.blogspot.in/2010/08/disableenable-javascript-in-internet.html and this http://stackoverflow.com/questions/12170944/how-can-you-programmatically-detect-if-javascript-is-enabled-disabled-in-a-windo but even these programs are returning javascript false. i am still getting the ajax page in webbrowser control. – Alok Nov 24 '13 at 13:30
  • The trick is to view a YT page in your browser, using a live AJAX viewer such as Firebug. You'll get a [link like this](http://www.youtube.com/watch_fragments_ajax?frags=guide&v=nwSzXu-L4IA&spf=load) that you can scrape using a simple POST op. The code looks like it is just the same as the code for the video itself. – halfer Nov 24 '13 at 22:14

0 Answers0