110,536
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 获取IE句柄
/// </summary>
/// <returns></returns>
private bool GetHandleOfBrowser()
{
IEHandle = FindWindowA("IEFrame", null);
if (IEHandle == 0)
return false;
else
return true;
}
/// <summary>
/// 根据元素信息获取坐标
/// </summary>
/// <param name="Id">元素ID</param>
/// <param name="TextStr">元素内容 格式: input|登 录</param>
/// <returns></returns>
public Rectangle GetElementPointByMess(out IHTMLElement2 TempYs,string IdStr = "", string TextStr = "")
{
int YsX = -1;
if (BrowserH < 1)
{
BrowserH=Screen.PrimaryScreen.WorkingArea.Height - ((IHTMLElement2)Document.documentElement).clientHeight;
}
int YsY = BrowserH;
int YsWith = -1;
int YsHeight = -1;
//int dsadsa = ((IHTMLElement2)Document.documentElement).clientHeight;
TempYs = null;
try
{
if (IdStr != "")
{
IHTMLElement2 TempElement = ((IHTMLElement2)Document.getElementById(IdStr));
YsX = TempElement.getBoundingClientRect().left;
YsY += TempElement.getBoundingClientRect().top;
YsWith = TempElement.scrollWidth;
YsHeight = TempElement.scrollHeight;
TempYs = TempElement;
}
else if (TextStr != "")
{
IHTMLElement2 TempElement = null;
foreach (IHTMLElement i in Document.getElementsByTagName(TextStr.Split('|')[0].Trim()))
{
if (i.innerText == TextStr.Split('|')[1])
{
TempElement = (IHTMLElement2)i;
break;
}
}
YsX = TempElement.getBoundingClientRect().left;
YsY += TempElement.getBoundingClientRect().top;
YsWith = TempElement.scrollWidth;
YsHeight = TempElement.scrollHeight;
TempYs = TempElement;
}
}
catch
{
return new Rectangle(-1, -1, -1, -1);
}
return new Rectangle(YsX, YsY, YsWith, YsHeight);
}
/// <summary>
/// 寻找子元素获取坐标
/// </summary>
/// <param name="TempYs">返回找到的元素</param>
/// <returns></returns>
public Rectangle GetElementPointByMess(out IHTMLElement2 TempYs)
{
int YsX = -1;
if (BrowserH < 1)
{
BrowserH = Screen.PrimaryScreen.WorkingArea.Height - ((IHTMLElement2)Document.documentElement).clientHeight;
}
int YsY = BrowserH;
int dsa = ((IHTMLElement2)Document.body).scrollHeight;
int YsWith = -1;
int YsHeight = -1;
TempYs = null;
try
{
IHTMLElement2 TempElement = null;
IHTMLElementCollection IeC = (IHTMLElementCollection)Document.all.tags("A");
TempElement = (IHTMLElement2)IeC.item("a", 0);
YsX = TempElement.getBoundingClientRect().left;
YsY += TempElement.getBoundingClientRect().top;
YsWith = TempElement.scrollWidth;
YsHeight = TempElement.scrollHeight;
TempYs = TempElement;
}
catch
{
return new Rectangle(-1, -1, -1, -1);
}
return new Rectangle(YsX, YsY, YsWith, YsHeight);
}
/// <summary>
/// 寻找子元素获取坐标
/// </summary>
/// <param name="TempYs">返回找到的元素</param>
/// <param name="TextStr">table|blog.tianya.cn|a|天涯</param>
/// <returns></returns>
public Rectangle GetElementPointByMess(out IHTMLElement2 TempYs, string TextStr = "")
{
int YsX = -1;
if (BrowserH < 1)
{
BrowserH = Screen.PrimaryScreen.WorkingArea.Height - ((IHTMLElement2)Document.documentElement).clientHeight;
}
int YsY = BrowserH;
int dsa = ((IHTMLElement2)Document.body).scrollHeight;
int YsWith = -1;
int YsHeight = -1;
TempYs = null;
try
{
if (TextStr != "")
{
IHTMLElement2 TempElement = null;
foreach (IHTMLElement i in Document.getElementsByTagName(TextStr.Split('|')[0].Trim()))
{
if (i.innerText != null && i.innerText.Contains(TextStr.Split('|')[1]))
{
foreach (IHTMLElement y in (IHTMLElementCollection)((IHTMLElementCollection)i.all).tags("A"))//.GetElementsByName(TextStr.Split('|')[2].Trim()
{
if (y.innerText != null && y.innerText.Contains(TextStr.Split('|')[3]) && y.tagName == "A")
{
TempElement = (IHTMLElement2)y;
break;
}
}
if (TempElement != null)
break;
}
}
YsX = TempElement.getBoundingClientRect().left;
YsY += TempElement.getBoundingClientRect().top;
YsWith = TempElement.scrollWidth;
YsHeight = TempElement.scrollHeight;
TempYs = TempElement;
}
}
catch
{
return new Rectangle(-1, -1, -1, -1);
}
return new Rectangle(YsX, YsY, YsWith, YsHeight);
}
//设置浏览器版本
if (!RegSetting.SetReg(BrowserEnvironment_T[Rd.Next(BrowserEnvironment_T.Count)]))
continue;
MainForm.DisMes("伪装浏览器完成,启动浏览器中...");
//移动至输入框
IHTMLElement2 TempIH = null;
Rectangle Rt1 = NowBroswer.GetElementPointByMess(out TempIH, BroswerConfig[7].Substring(BroswerConfig[7].IndexOf("|") + 1), "");
MainForm.DisMes("移动至输入框...随机路径...");
if (MainForm.StopAll)
return;
MouseMove(new Point(Rd.Next(Rt1.X + 10, Rt1.X + Rt1.Width - 10), Rd.Next(Rt1.Y + 10, Rt1.Y + Rt1.Height - 10)));
if (MainForm.StopAll)
return;
MainForm.DisMes("点击鼠标左键");
支持格式替换。。。这个应该能明白。。。
好吧 那个自动判断输入出错的忘记加上了
以后加上。。。
这东西用 可连数据库 可用代理。。。
vps 20多台 跑了 3天没任何问题
就代理验证的服务器有点问题
重启代理服务器 这20多台vps又开始了。。。
就是求点下载分。。。我容易么。。。