我正在使用HtmlAgilityPack从这个站点中获取一些足球事件。
我正在捕捉的事件在All选项卡中。从本质上讲,我所做的就是得到所有事件所在的表,如下所示:
string url = "http://it.soccerway.com/";
string data = new WebClient().DownloadString(url);
var doc = new HtmlDocument();
doc.LoadHtml(data);
var table = doc.DocumentNode.SelectSingleNode("//table[@class='matches date_matches grouped ']");在下一次我获得所有可见事件时,所有具有类group-head expanded loaded的div
var tableTrHeader = table.SelectNodes("//tr[@class='group-head expanded loaded ']");然后再重复一遍。所有这些都很好,但我有个问题。事实上,表中还有其他事件,但不幸的是,这个事件没有类loaded,而只是拥有:group-head clickable。
因此,我想站点的js代码中有执行操作的内容,或者类似于获取单击行的详细信息的内容。
我想加载一个html,它扩展了所有的条目,但不幸的是,我不知道一种方法,它允许我通过c#对特定的目标html元素发送单击操作。我认为HtmlAgilityPack不是针对这个目标完成的,而是只为抓取而完成的。
有人能解决这个问题吗?谢谢。
发布于 2016-09-02 11:25:23
我认为HtmlAgilityPack不是针对这个目标完成的,而是只为抓取而完成的。
正确的。
有人能解决这个问题吗?
这在很大程度上取决于它的实现方式。如果是JavaScript,那祝你好运。您可能需要切换整个工具链,转而使用浏览器自动化。
如果它是一个HtmlAgilityPack链接,获取该链接,发出另一个请求并再次使用HtmlAgilityPack解析它。
发布于 2016-09-02 11:23:45
我发现了这个:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class Form1 : Form
{
[DllImport("user32.dll",CharSet=CharSet.Auto, CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
public Form1()
{
}
public void DoMouseClick()
{
//Call the imported function with the cursor's current position
int X = Cursor.Position.X;
int Y = Cursor.Position.Y;
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
}
//...other code needed for the application
}这里,看一看:)
https://stackoverflow.com/questions/39290939
复制相似问题