本文整理汇总了C#中System.Windows.Forms.HtmlDocument类的典型用法代码示例。如果您正苦于以下问题:C# HtmlDocument类的具体用法?C# HtmlDocument怎么用?C# HtmlDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HtmlDocument类属于System.Windows.Forms命名空间,在下文中一共展示了HtmlDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: AttachValueToDataSource
public static void AttachValueToDataSource(DataSet ds, HtmlDocument doc)
{
LoggingService.DebugFormatted("绑定HTML表单数据:{0} 到数据源...", new object[] { doc.Url });
foreach (string str in tags)
{
HtmlElementCollection elementsByTagName = doc.GetElementsByTagName(str);
foreach (HtmlElement element in elementsByTagName)
{
DataRow row;
string attribute = element.GetAttribute("dbtable");
string str3 = element.GetAttribute("dbcolumn");
if (GetDataRow(ds, attribute, out row) && (row != null))
{
if (row.RowState == DataRowState.Unchanged)
{
row.SetModified();
}
if (!(string.IsNullOrEmpty(str3) || !row.Table.Columns.Contains(str3)))
{
string str4 = element.GetAttribute("value").Trim();
row[str3] = (str4 == string.Empty) ? Convert.DBNull : str4;
LoggingService.DebugFormatted("设置表:{0}列:{1}的值为:{2}", new object[] { attribute, str3, str4 });
}
}
}
}
}
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:27,代码来源:WebBrowserExtensions.cs
示例2: LoadJsFile
public static bool LoadJsFile(HtmlDocument doc, string js)
{
bool noErr = true;
string file = String.Empty;
try
{
string[] files = js.Split(new char[] { ',' });
foreach (string f in files)
{
file = GlobalVar.AppPath + "res\\" + f + ".js";
string s = Utility.ReadFile(file);
noErr &= !String.IsNullOrEmpty(s);
if(String.IsNullOrEmpty(s))
GlobalVar.Log.LogError("取得文件内空为空!",file);
ExecScript(doc, s);
}
doc.Write("<script language='javascript'>alert('hello');</script>");
}
catch (System.Exception )
{
MessageBox.Show("load [" + file + "] error");
return false;
}
return noErr;
}
开发者ID:kener1985,项目名称:MyGitHubProj,代码行数:31,代码来源:ScriptUtility.cs
示例3: DOMTreeToXml
private static XmlDocument DOMTreeToXml(HtmlDocument htmlDoc)
{
XmlDocument result = new XmlDocument();
if(htmlDoc != null &&
htmlDoc.Body != null &&
htmlDoc.Body.Parent != null)
{
HtmlElement topHtml = htmlDoc.Body.Parent;
using (StringReader sReader = new StringReader(topHtml.OuterHtml))
{
using (StringWriter errorLog = new StringWriter())
{
Sgml.SgmlReader reader = new Sgml.SgmlReader();
reader.ErrorLog = errorLog;
reader.InputStream = sReader;
using (StringReader dtdReader = new StringReader(Properties.Resources.WeakHtml))
reader.Dtd = Sgml.SgmlDtd.Parse(null, "HTML", null, dtdReader, null, null, reader.NameTable);
result.Load(reader);
errorLog.Flush();
Console.WriteLine(errorLog.ToString());
}
}
}
return result;
}
开发者ID:rushit-dawda,项目名称:content-extractor,代码行数:26,代码来源:WebDocument.cs
示例4: DownloadInfo
public DownloadInfo(Uri projectUrl, Uri articleUrl, HtmlDocument htmlDocument)
{
m_projectUrl = projectUrl;
m_articleUrl = articleUrl;
m_htmlDocument = htmlDocument;
ParseCookies(htmlDocument.Cookie);
}
开发者ID:bcokur,项目名称:mydotnetsamples,代码行数:7,代码来源:DownloadInfo.cs
示例5: Download
public Download(HtmlDocument document, string key, string url, string filename)
{
this.url = url;
this.key = key;
this.document = document;
target = Path.Combine(Path.GetTempPath(), filename);
if (File.Exists(target))
status = DownloadStatus.DOWNLOADED;
else
status = DownloadStatus.AVAILABLE;
downloadBGWorker = new BackgroundWorker()
{
WorkerReportsProgress = true,
WorkerSupportsCancellation = true
};
downloadBGWorker.DoWork += RunDownload;
downloadBGWorker.ProgressChanged += UpdateProgress;
downloadBGWorker.RunWorkerCompleted += DownloadFinished;
extractBGWorker = new BackgroundWorker();
extractBGWorker.DoWork += DoExtraction;
extractBGWorker.RunWorkerCompleted += ExtractionFinished;
}
开发者ID:patthoyts,项目名称:OpenRA,代码行数:26,代码来源:Download.cs
示例6: ParseSeries
private Series ParseSeries(HtmlDocument doc)
{
var result = new Series();
result.Title = Find(FindTitle, doc);
result.Description = Find(FindDescription, doc);
return result;
}
开发者ID:ngprice,项目名称:wcscrape,代码行数:8,代码来源:Index.cs
示例7: DisplayInTree
/// <summary>
/// Display an HTML document in the tree view, organizing the tree
/// in accordance with the Document Object Model (DOM)
/// </summary>
/// <param name="docResponse">the document to display</param>
/// <remarks><para>Called by the thread.start to set up for filling the DOM tree</para>
/// Has to be passed as an object for the ParameterizedThreadStart</remarks>
public void DisplayInTree(HtmlDocument docResponse)
{
HtmlElementCollection elemColl = docResponse.GetElementsByTagName("html");
_treeView.Nodes.Clear();
var rootNode = new TreeNode("Web response") {Tag = -1};
_treeView.Nodes.Add(rootNode);
FillDomTree(elemColl, rootNode, 0);
}
开发者ID:jcvlcek,项目名称:DenniHlasatelDeathIndexExplorer,代码行数:16,代码来源:TreeViewWrapper.cs
示例8: FindTitle
private string FindTitle(HtmlDocument doc)
{
var result = String.Empty;
IQueryable<HtmlElement> h1HEC = doc.GetElementsByTagName("h1").AsQueryable().Cast<HtmlElement>();
var titleElement = h1HEC.First(e => e.GetAttribute("class") == "title");
return result;
}
开发者ID:ngprice,项目名称:wcscrape,代码行数:9,代码来源:Index.cs
示例9: GetOrCreateDocumentHandle
public static HtmlDocumentHandle GetOrCreateDocumentHandle(HtmlDocument htmlDocument)
{
var guidObj = htmlDocument.InvokeScript (c_getDocumentIdentification);
var docID = guidObj != null ? new HtmlDocumentHandle (Guid.Parse (guidObj.ToString())) : new HtmlDocumentHandle (Guid.NewGuid());
htmlDocument.InvokeScript (c_addDocumentIdentification, new object[] { docID.ToString() });
return docID;
}
开发者ID:rubicon-oss,项目名称:DesktopGap,代码行数:9,代码来源:DocumentIdentifier.cs
示例10: Create
public static IBoodProduct Create(HtmlDocument doc)
{
try {
var all = doc.All.Cast<HtmlElement>();
var imgs = doc.Images.Cast<HtmlElement>();
var img = GetElement(all, "IMG", "className", "main-prod-img") ?? imgs.FirstOrDefault(i => i.OuterHtml.Contains("class=main-prod-img"));
var prodName = string.Empty;
var prodImage = string.Empty;
if (img != null) {
prodName = img.GetAttribute("alt");
prodImage = img.GetAttribute("src");
}
var spanOldPrice = GetElement(all, "SPAN", "className", "old-price");
decimal oldPrice = 0;
try {
oldPrice = decimal.Parse(spanOldPrice.InnerText, System.Globalization.NumberStyles.Currency);
}
catch { }
var spanOurPrice = GetElement(all, "P", "className", "our-price");
decimal ourPrice = 0;
decimal shippingCost = 0;
try {
// "iBOOD PrijsNu! € 149,95 + (8,95) "
var priceParts = spanOurPrice.InnerText.Split(new char[] {'€', ' ', '+', '(' ,')'}, StringSplitOptions.RemoveEmptyEntries );
shippingCost = decimal.Parse(priceParts[2]);
ourPrice = decimal.Parse(priceParts[3]); //decimal.Parse(spanOurPrice.InnerText, System.Globalization.NumberStyles.Currency);
}
catch { }
var divIsSoldOut = GetElement(all, "DIV", "id", "issoldout");
var isSoldOut = divIsSoldOut != null && divIsSoldOut.Style.ToLower() == "display:none";
var aMoreInfo = GetElement(all, "A", "id", "speclink");
var moreInfoUri = aMoreInfo.GetAttribute("href");
var aBuyNow = GetElement(all, "A", "id", "btnbuy");
var buyNowUri = aBuyNow.GetAttribute("href");
return new IBoodProduct {
Name = prodName,
ImageUri = new Uri(prodImage),
Status = isSoldOut ? ProductStatus.IsSoldOut : ProductStatus.NotSoldOut,
RegularPrice = oldPrice,
OurPrice= ourPrice ,
ShippingCost = shippingCost,
MoreInfoUri = new Uri(moreInfoUri),
BuyNowUri = new Uri(buyNowUri)
};
}
catch { }
return null;
}
开发者ID:dieterm,项目名称:IBoodHuntMonitor,代码行数:56,代码来源:IBoodProduct.cs
示例11: HtmlDocumentAdapter
public HtmlDocumentAdapter( HtmlDocument doc )
{
if ( doc == null )
{
throw new ArgumentNullException( "doc" );
}
Document = doc;
myElementAdapters = new Dictionary<HtmlElement, HtmlElementAdapter>();
}
开发者ID:bg0jr,项目名称:Maui,代码行数:10,代码来源:HtmlDocumentAdapter.cs
示例12: WebEngine
public WebEngine(HtmlDocument document, string webRoot)
{
_document = document;
_webRoot = webRoot;
session = engine.CreateSession(document);
session.AddReference("System.Windows.Forms");
RegisterEvents();
CompileScripts();
}
开发者ID:ZanderAdam,项目名称:Roslyn-Web-Scripting,代码行数:11,代码来源:WebEngine.cs
示例13: ScrapePage
public void ScrapePage(HtmlDocument link)
{
CurrentDoc = link;
TableData.Add(CurrentDoc.GetElementById("ctl00_cphBody_repeaterOwnerInformation_ctl00_lblOwnerName").InnerText);
TableData.Add(CurrentDoc.GetElementById("ctl00_cphBody_lblHeaderPropertyAddress").InnerText);
ScrapeHTMLTables("buildingsDetailWrapper", "table", 0);
ScrapeHTMLTables("buildingsDetailWrapper", "table", 1);
ScrapeHTMLTables("buildingsDetailWrapper", "table", 3);
RemoveUnneededListElements();
}
开发者ID:josecerejo,项目名称:PageScraper,代码行数:11,代码来源:COJScraper.cs
示例14: SetFileUpload
protected void SetFileUpload(HtmlDocument document, string name, string fileName)
{
var fileElement = (HTMLInputElement)document.GetElementById(name).DomElement;
fileElement.focus();
// The first space is to open the file open dialog. The
// remainder of the spaces is to have some messages for
// until the open dialog actually opens.
SendKeys.SendWait(" " + fileName + "{ENTER}");
}
开发者ID:smile921,项目名称:hak_blog,代码行数:12,代码来源:WebBrowserFixtureBase.cs
示例15: ExecScript
public static object ExecScript(HtmlDocument doc, string js)
{
object ret = null;
if (String.IsNullOrEmpty(js) == false)
{
mshtml.IHTMLDocument2 d = doc.DomDocument as mshtml.IHTMLDocument2;
mshtml.IHTMLWindow2 win = d.parentWindow as mshtml.IHTMLWindow2;
ret = win.execScript(js, "javascript");
}
return ret;
}
开发者ID:kener1985,项目名称:MyGitHubProj,代码行数:13,代码来源:ScriptUtility.cs
示例16: GetPostData
private Dictionary<String, String> GetPostData(HtmlDocument doc,string formName, Uri target, Uri baseURL)
{
Dictionary<String, String> ret = new Dictionary<String, String>();
foreach (HtmlElement form in doc.GetElementsByTagName("save_passenger_single"))
if ((form.GetAttribute("mode").ToLower() == "post") && ((target == (new Uri(baseURL, form.GetAttribute("target"))))))
foreach (HtmlElement widget in form.GetElementsByTagName("input"))
{
String name = widget.GetAttribute("name");
if (name != "")
ret.Add(name, widget.GetAttribute("value"));
}
return ret;
}
开发者ID:340211173,项目名称:hf-2011,代码行数:13,代码来源:TickerWebBrowser.cs
示例17: BodyLoaded
private void BodyLoaded(HtmlDocument doc)
{
outputSheet = new OutputSheet(doc);
interpreter = new Interpreter(outputSheet);
input.KeyPress += (sender, e) => {
if (e.KeyChar == 13) {
OnEnter();
e.Handled = true;
}
};
input.Focus();
}
开发者ID:paul-nechifor,项目名称:or-homework,代码行数:14,代码来源:MainWindow.cs
示例18: Process
public override void Process(HtmlDocument doc)
{
Processed = true;
HtmlElement details = null;
bool hasAddress = false;
bool hasDetails = false;
foreach (HtmlElement div in doc.GetElementsByTagName("div"))
{
String cn = div.GetAttribute("className");
if (cn == "cop_address")
{
Address = div.InnerText;
hasAddress = true;
}
else if (cn == "cop_contact_inf")
{
details = div;
hasDetails = true;
}
if (hasAddress && hasDetails)
break;
}
// process details
foreach (HtmlElement li in details.GetElementsByTagName("li"))
{
String cname = li.FirstChild.GetAttribute("className");
if (cname == "call_i")
{
Phones.Add(li.Children[1].InnerText.Trim());
}
else if (cname == "web_i")
{
Sites.Add(li.Children[1].InnerText.Trim());
}
else
{
MessageBox.Show(Url.ToString() + ": " + cname);
}
}
// coordinates
MatchCollection matches = Regex.Matches(doc.Body.InnerHtml, "google\\.maps\\.LatLng\\((.*?)\\)");
if (matches.Count > 0)
{
Coords = matches[0].Groups[1].Value;
}
}
开发者ID:Infarch,项目名称:MyPerlModules,代码行数:49,代码来源:Leaf.cs
示例19: GetFaviconUrl
private static string GetFaviconUrl(HtmlDocument document)
{
if (document == null)
throw new NullReferenceException("Document should not be null!");
if (document.Body == null)
return GetDefaultFavicon(document.Url);
var regex = new Regex("<link\\s+rel=\"shortcut icon\"\\s+href=\"(.+)\">");
var matches = regex.Match(document.Body.InnerHtml);
if (matches.Length == 0 || matches.Captures.Count < 1)
return GetDefaultFavicon(document.Url);
return matches.Captures[1].Value;
}
开发者ID:xinhuang,项目名称:BrowserApp,代码行数:15,代码来源:MainForm.cs
示例20: GetPic
/// <summary>
/// 得到验证码图片
/// </summary>
/// <param name="doc"></param>
/// <param name="ImgName"></param>
/// <returns></returns>
public static Image GetPic(HtmlDocument doc, string ImgName)
{
Image RegImg;
HTMLDocument domDoc = (HTMLDocument)doc.DomDocument;
HTMLBody body = (HTMLBody)domDoc.body;
IHTMLControlRange rang = (IHTMLControlRange)body.createControlRange();
IHTMLControlElement Img;
Img = (IHTMLControlElement)doc.All[ImgName].DomElement;
rang.add(Img);
rang.execCommand("Copy", false, null);
RegImg = Clipboard.GetImage();
Clipboard.Clear(); return RegImg;
}
开发者ID:340211173,项目名称:hf-2011,代码行数:22,代码来源:CommUitl.cs
注:本文中的System.Windows.Forms.HtmlDocument类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论