Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Question about grabbing webpage using WebBrowser Control. [modified]

Question about grabbing webpage using WebBrowser Control. [modified]

Scheduled Pinned Locked Moved C#
questionjavascriptcomhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rryyjw
    wrote on last edited by
    #1

    Hi All, I want to load a page using WebBrowser Control (see code below). I try to get the page content through DocumentText property in "DocumentCompleted" event handler, but it seems that the event won't be triggered. The "Navigated" event won't be triggered either. However, the "Navigating" event does. I used to use HttpWebRequest/HttpWebResponse to grab webpage content, however, the drawback is that I can't get the full loaded page through it. What I mean by this is that maybe some javascript will execute to modify elements on the page after it's loaded, I call this page as full loaded page. I think using WebBrowser Control can overcome this drawback. It's just like a browser, and it'll execute those javascript after loading the page. But I can't make this control work correctly. Could anyone help me? I'm very appreciate. Thanks Jie using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; namespace ConsoleApplication1 { class Program { static WebBrowser wb; [STAThread] static void Main(string[] args) { Go(); } private static void Go() { wb = new WebBrowser(); wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(wb_DocumentCompleted); wb.Navigating +=new WebBrowserNavigatingEventHandler(wb_Navigating); wb.Navigated += new WebBrowserNavigatedEventHandler(wb_Navigated); wb.Navigate("http://www.google.com"); Console.ReadLine(); } static void wb_Navigating(object sender, WebBrowserNavigatingEventArgs e) { Console.WriteLine("Navigating"); } static void wb_Navigated(object sender, WebBrowserNavigatedEventArgs e) { Console.WriteLine("Navigated"); } static void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { Console.WriteLine("DocumentCompleted"); Console.WriteLine(wb.DocumentText); } } } -- modified at 10:06 Thursday 14th September, 2006

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups