简体   繁体   中英

geckofx GeckoElementCollection don't work for me

I am new to c #, I'm trying to do small experiments with geckofx. I can navigate, but I have a problem with the DOM of html. I don't understand why this simple piece of code does not write the links are on the page. took hours proving different things but nothing works, someone can tell me where I am wrong here.

Thank you for your time in advance.

Sorry for my bad english, I'm learning it!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Skybound.Gecko;
using System.Diagnostics;

namespace WindowsFormsApplication8
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            String xulPath = Application.StartupPath + "\\xulrunner\\";
            Xpcom.Initialize(xulPath);
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            web.Navigate("http://es.wikipedia.org/wiki/Blog");
            System.Threading.Thread.Sleep(25000);
            Debug.WriteLine("hola");
            GeckoElementCollection links = web.Document.GetElementsByTagName("a");
            foreach (GeckoElement link in links)
            {
                Debug.WriteLine(link.GetAttribute("href"));
            }


        }

        private void web_Click(object sender, EventArgs e)
        {

        }




    }
}

解决的问题是,程序没有时间在搜索链接之前加载页面,而方法thread.sleep并没有给程序时间来停止它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM