IHTMLDocument2类的使用
class Program
{
static void Main(string[] args)
{
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
string filename;
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filename = "iexplore";// Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals("iexplore"))
{
Console.WriteLine("Web Site : {0}", ie.LocationURL);
mshtml.IHTMLDocument2 htmlDoc = ie.Document as mshtml.IHTMLDocument2;
Console.WriteLine(" Document Snippet: {0}", ((htmlDoc != null) ? htmlDoc.body.outerHTML.Substring(0, 40) : "***Failed***"));
if (ie.LocationURL == "http://s.taobao.com/search?q=%D2%C2%B7%FE&initiative_id=tbindexz_20130105&commend=all&source=suggest&ssid=s5-e-p1&suggest=0_3&newpre=null&bcoffset=1&s=40#J_FilterTabBar")
{
SearchTextInGoogle(htmlDoc, "衣服");
}
Console.WriteLine("{0}{0}", Environment.NewLine);
}
}
Console.WriteLine("完成");
Console.ReadLine();
}
public static void SearchTextInGoogle(mshtml.IHTMLDocument2 ieDoc, string searchText)
{
mshtml.HTMLInputElement input;
//set the text to be searched
//foreach (mshtml.IHTMLElement ieElement in ieDoc.all)
//{
// //if its tag is input and name is q(question)
// if (ieElement.tagName.ToUpper() == "INPUT")
// {
// input = ((mshtml.HTMLInputElement)ieElement);
// if (input.name == "wd")
// {
// input.value = searchText;
// //break;
// }
// }
//}
//click the submit button to search
foreach (mshtml.IHTMLElement ieElement in ieDoc.all)
{
//if its tag is input
if (ieElement.tagName.ToUpper() == "A")
{
if (ieElement.className == "page-next")
{
ieElement.click();
}
}
}
}
}
最新文章
- HashMap的内部实现机制,Hash是怎样实现的,什么时候ReHash
- linux apt-get install 错误: Package has no installation candidate
- 王爽 <;<;汇编 语言>;>; 13.6 BIOS中断例程应用
- C4.5算法
- Java基础(30):String对象的常用方法与实例(String类)
- 总结Selenium自动化测试方法(六)常见的异常错误处理
- BZOJ_1002_[FJOI2007]_轮状病毒_(递推+高精)
- Android WebView JavaScript交互
- 解决WCF 调用方未由服务器进行身份验证或消息包含无效或过期的安全上下文令牌
- 使用批处理根据项目工程文件生成Nuget包并发布(支持.NET Core)
- EF6与Mysql疑难问题记录
- rsync的详细配置
- Azure Sphere–“Object reference not set to an instance of an object” 解决办法
- Typescript中抽象类与接口详细对比与应用场景介绍
- JavaBean-EL-JSTL-MVC
- hbase 1.2.1 分布式安装
- 了解一下UTF-16
- right spindle supply short to gnd-- compact version
- TOJ3448: 小学生的作业
- apt-get install 和 pip install的区别
热门文章
- hdu 2149 (巴什博奕)
- 网络分层和Http协议原理
- COGS 2392 2393 2395 有标号的二分图计数
- tyvj/joyoi 1374 火车进出栈问题(水水版)
- 当我new class的时候,提示以下错误: Unable to parse template ";Class"; Error message: This template did not produce a Java class or an interface Error parsing file template: Unable to find resource &#39;Package Header.j
- 第一个java程序的编译
- node(基础)_node中的javascript
- vue的一些小坑
- CentOS7 下 Hadoop 单节点(伪分布式)部署
- Android中不显示标题