使用 HtmlAgilityPack 的 C# 网页抓取

C# web scraping with HtmlAgilityPack

I want to create application in WPF wchich will scrape information from webpage

I read link to the page from text box at the top

I want to extract company name from h6

我不明白这种格式:"//h2[@class='card__title mdc-typography--headline6']"。我找不到文档 abot 意思是 @ [] 等来创建另一个过滤器来 scrape 其他数据,例如来自标签的 phone 数字。

@, //, ... 表示 XPath 选择器的缩写语法。

  • @abc is short for attribute::abc
  • // is short for /descendant-or-self::node()/

因此,换句话说,您当前的查询 //h2[@class='card__title mdc-typography--headline6'] 表示查找第一个 class 属性为 card__title mdc-typography--headline6 的后代节点或自节点的操作。