[英]geckofx GeckoElementCollection don't work for me
我是C#的新手,我正在尝试使用geckofx进行小型实验。 我可以导航,但是html的DOM有问题。 我不明白为什么这段简单的代码没有写链接在页面上。 花了几个小时证明了不同的东西,但是没有任何效果,有人可以告诉我我在哪里错了。
谢谢您的宝贵时间。
对不起,我的英语不好,我正在学习!
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并没有给程序时间来停止它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.