GithubHelp home page GithubHelp logo

antchfx / htmlquery Goto Github PK

View Code? Open in Web Editor NEW
702.0 11.0 70.0 138 KB

htmlquery is golang XPath package for HTML query.

Home Page: https://github.com/antchfx/xpath

License: MIT License

Go 100.00%
html xpath html-parser golang xpath-selector go xpath2

htmlquery's Introduction

htmlquery

Build Status GoDoc Go Report Card

Overview

htmlquery is an XPath query package for HTML, lets you extract data or evaluate from HTML documents by an XPath expression.

htmlquery built-in the query object caching feature based on LRU, this feature will caching the recently used XPATH query string. Enable query caching can avoid re-compile XPath expression each query.

You can visit this page to learn about the supported XPath(1.0/2.0) syntax. https://github.com/antchfx/xpath

XPath query packages for Go

Name Description
htmlquery XPath query package for the HTML document
xmlquery XPath query package for the XML document
jsonquery XPath query package for the JSON document

Installation

go get github.com/antchfx/htmlquery

Getting Started

Query, returns matched elements or error.

nodes, err := htmlquery.QueryAll(doc, "//a")
if err != nil {
	panic(`not a valid XPath expression.`)
}

Load HTML document from URL.

doc, err := htmlquery.LoadURL("http://example.com/")

Load HTML from document.

filePath := "/home/user/sample.html"
doc, err := htmlquery.LoadDoc(filePath)

Load HTML document from string.

s := `<html>....</html>`
doc, err := htmlquery.Parse(strings.NewReader(s))

Find all A elements.

list := htmlquery.Find(doc, "//a")

Find all A elements that have href attribute.

list := htmlquery.Find(doc, "//a[@href]")

Find all A elements with href attribute and only return href value.

list := htmlquery.Find(doc, "//a/@href")
for _ , n := range list{
	fmt.Println(htmlquery.InnerText(n)) // output @href value
}

Find the third A element.

a := htmlquery.FindOne(doc, "//a[3]")

Find children element (img) under A href and print the source

a := htmlquery.FindOne(doc, "//a")
img := htmlquery.FindOne(a, "//img")
fmt.Prinln(htmlquery.SelectAttr(img, "src")) // output @src value

Evaluate the number of all IMG element.

expr, _ := xpath.Compile("count(//img)")
v := expr.Evaluate(htmlquery.CreateXPathNavigator(doc)).(float64)
fmt.Printf("total count is %f", v)

Quick Starts

func main() {
	doc, err := htmlquery.LoadURL("https://www.bing.com/search?q=golang")
	if err != nil {
		panic(err)
	}
	// Find all news item.
	list, err := htmlquery.QueryAll(doc, "//ol/li")
	if err != nil {
		panic(err)
	}
	for i, n := range list {
		a := htmlquery.FindOne(n, "//a")
		if a != nil {
		    fmt.Printf("%d %s(%s)\n", i, htmlquery.InnerText(a), htmlquery.SelectAttr(a, "href"))
		}
	}
}

FAQ

Find() vs QueryAll(), which is better?

Find and QueryAll both do the same things, searches all of matched html nodes. The Find will panics if you give an error XPath query, but QueryAll will return an error for you.

Can I save my query expression object for the next query?

Yes, you can. We offer the QuerySelector and QuerySelectorAll methods, It will accept your query expression object.

Cache a query expression object(or reused) will avoid re-compile XPath query expression, improve your query performance.

XPath query object cache performance

goos: windows
goarch: amd64
pkg: github.com/antchfx/htmlquery
BenchmarkSelectorCache-4                20000000                55.2 ns/op
BenchmarkDisableSelectorCache-4           500000              3162 ns/op

How to disable caching?

htmlquery.DisableSelectorCache = true

Questions

Please let me know if you have any questions.

htmlquery's People

Contributors

atakanozceviz avatar dependabot[bot] avatar egginabucket avatar fahimbagar avatar ffigiel avatar highway900 avatar mildred avatar moredure avatar subsr97 avatar zaba505 avatar zhengchun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

htmlquery's Issues

[bug] htmlquery.QueryAll not returning all node attribute results

It seems that the nodup fix from #6 causes attributes that have the same value with the first result to be discarded
Example (only used for testing) taken from #20 and adjusted

package main

import (
        "fmt"
        "strings"

        "github.com/antchfx/htmlquery"
)

func main() {
        t := []string{
                "<span class='output' sup='24'></span><span class='output' sup='24'></span><span class='output' sup='45'></span>",
                "<span class='output' sup='24'></span><span class='output' sup='45'></span><span class='output' sup='45'></span>",
                "<span class='output' sup='45'></span><span class='output' sup='24'></span><span class='output' sup='45'></span>",
        }

        for _, s := range t {
                doc, _ := htmlquery.Parse(strings.NewReader(s))
                nx, _ := htmlquery.QueryAll(doc, "//span[@class='output']/@sup")
                for _, n := range nx {
                        fmt.Println(htmlquery.InnerText(n))
                }
                fmt.Println("--")
        }
}

Output

24
45
--
24
45
45
--
45
24
--

Expected Output

24
24
45
--
24
45
45
--
45
24
45
--

Strange result

I have a strange result when checking some stuff, and I was able to reproduce it

	memHtml = "<html><head></head><body><td>check</td></body></html>"

	docLoc, err := htmlquery.Parse(strings.NewReader(memHtml))
	if err != nil {
		panic(err)
	}

	test := htmlquery.OutputHTML(docLoc, false)

test is now:

   <html><head></head><body>check</body></html>

Why are the td-tags missing here?

'Evaluate' may return incorrect result ?

Hello,
First of all, thank you for you work, I really appreciate the quality of the lib.
I've a strange result with a simple html file:

<html>
	<body>
		<div class="fruit">Apple</div>
		<div class="fruit">Banana</div>
		<div class="fruit">Lemon</div>
	</body>
</html>

I think the two following XPath expression string((//div)[2]) and string((//div[@class="fruit"])[2]) should give the same result. In my comprehension, the two expression select the second div and string function should return Banana. But the second one returns an empty string :

         html := `<html>
	<body>
		<div class="fruit">Apple</div>
		<div class="fruit">Banana</div>
		<div class="fruit">Lemon</div>
	</body>
	</html>`

	doc, _ := htmlquery.Parse(strings.NewReader(html))

	test1 := `string((//div)[2])`
	expr1, _ := xpath.Compile(test1)
	v1 := expr1.Evaluate(htmlquery.CreateXPathNavigator(doc))
	// v1 = "Banana"

	test2 := `string((//div[@class="fruit"])[2])`
	expr2, _ := xpath.Compile(test2)
	v2 := expr2.Evaluate(htmlquery.CreateXPathNavigator(doc))
	// v2 = ""

Do you have any idea or I'm wrong ?

Thank you

Jc

Is it a bug?

`func main() {

doc, err := htmlquery.LoadURL(`http://episcopia-ungheni.md/ru/fara-categorie-ru/%d0%b0%d0%ba%d0%b0%d1%84%d0%b8%d1%81%d1%82%d0%bd%d0%be%d0%b5-%d0%bf%d0%b5%d0%bd%d0%b8%d0%b5-%d0%bf%d0%b5%d1%80%d0%b5%d0%b4-%d0%b8%d0%ba%d0%be%d0%bd%d0%be%d0%b9-%d0%b1%d0%be%d0%b6%d0%b8%d0%b5%d0%b9-5/`)
if err != nil {
	log.Println(err)
}
for i, v := range htmlquery.Find(doc, `//*[contains(@class,"gallery")]//a/@href`) {
	t := htmlquery.InnerText(v)
	fmt.Println(i, strings.TrimSpace(t))
}

}`

In other programs I got 1 url.
And this I got 4 same urls.
From source code it's 1 url.

LoadURL sometimes can not get the right page

seggest add the follow code:
req, _ := http.NewRequest("GET", url, nil)
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3776.0 Safari/537.36")
client := &http.Client{Timeout: time.Second * 5}
resp, err := client.Do(req)

Attribute selector bug?

Hello,

I think the attribute selector, e.g. "@href", should return the value of the attribute, NOT the name of the attribute.

func TestAttributeSelector(t * testing.T) {

	s := `<doc><a href="example.com"></a></doc>`
	doc, _ := htmlquery.Parse(strings.NewReader(s))
	a := htmlquery.FindOne(doc, "//a/@href")
	if a.Data != "example.com" {
		t.Errorf("Expected 'example.com' : got %s", a.Data)
	}
}

Slow parsing of multiple xpath expression

For the following URL : https://victorious.fandom.com/wiki/Gallery:Victorious_Cast_in_Real_Life if you do a simple find like in code blow, the parser will take a few minute to get done:

nodes := htmlquery.Find(
		doc, # the html document
		"//div/@data-src | //link/@href | //img/@src | //img/@data-src | //img/@image-src | //div/@data-imgsrc | //object/@data | //a/@href | //span/@data-href | //img/@srcset | //source/@data-srcset | //li/@data-src | //source/@srcset")

Let me know if a pprof will help or if you need anything else from me.
Thank you very much for the work on this library, otherwise it works really great at scale.

How can I get a attribute value?

xpath is like this: //div[@Class='blog-single-foot']/span[@Class='pull-left']/a/@href
but I can't get the right value of the href attribute, I don't want to use
xpath like: //div[@Class='blog-single-foot']/span[@Class='pull-left']/a
and then do htmlquery.SelectAttr(a, "href"), I just want to get the attribute directly, can anyone tell me why?

Add configurable timeout to LoadURL

The LoadURL method should have a timeout parameter to avoid indefinite load time.
Optionally, it could also accept any other client parameters.

func LoadURL(url string, clientOpts ...*http.Client) (*html.Node, error) {

}

How check an object exist or not

I have problem with this example code:
htmlquery.Find(doc, //tbody/tr//td/div[1]/@title)
and get this error:
invalid memory address or nil pointer dereference....
which is true, but I want to manage it to not stop the process and just ignore and pass through it. or before check for find be sure that is exist.
any solution?

Panic when querying malformed xpath

Added the following to TestXPath in query_test.go:

_, err := QueryAll(testDoc, "$test/@attr")

I'd expect this to return an error during parsing due to the badly formed xpath. Instead, it causes a panic:

--- FAIL: TestXPath (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x543fd5]

goroutine 15 [running]:
testing.tRunner.func1.1(0x7423c0, 0xaee130)
        c:/go/src/testing/testing.go:940 +0x2fc
testing.tRunner.func1(0xc000111200)
        c:/go/src/testing/testing.go:943 +0x400
panic(0x7423c0, 0xaee130)
        c:/go/src/runtime/panic.go:969 +0x174
github.com/antchfx/xpath.(*attributeQuery).Clone(0xc0000054c0, 0xc000005520, 0x728220)
        C:/Users/.../go/pkg/mod/github.com/antchfx/[email protected]/query.go:164 +0x35
github.com/antchfx/xpath.(*Expr).Select(...)
        C:/Users/.../go/pkg/mod/github.com/antchfx/[email protected]/xpath.go:131
github.com/antchfx/htmlquery.QuerySelectorAll(0xc00010a230, 0xc0000054e0, 0xc0000054e0, 0x0, 0x0)
        D:/dev/htmlquery/query.go:82 +0x91
github.com/antchfx/htmlquery.QueryAll(0xc00010a230, 0x7ad043, 0xb, 0xc000191500, 0x0, 0x0, 0xa2b565, 0x1c)
        D:/dev/htmlquery/query.go:54 +0x8c
github.com/antchfx/htmlquery.TestXPath(0xc000111200)
        D:/dev/htmlquery/query_test.go:150 +0x2c1
testing.tRunner(0xc000111200, 0x7cbd00)
        c:/go/src/testing/testing.go:991 +0xe3
created by testing.(*T).Run
        c:/go/src/testing/testing.go:1042 +0x35e
exit status 2
FAIL    github.com/antchfx/htmlquery    0.270s

The example fails in ubuntu 20.04

Trying to use FindOne (and failing) I ended up testing the example as in the README.md

~/golang $ cat example.go
package main

import (
    "fmt"
    "github.com/antchfx/htmlquery"
)
 func main() {
	doc, err := htmlquery.LoadURL("https://www.bing.com/search?q=golang")
	if err != nil {
		panic(err)
	}
	// Find all news item.
	list, err := htmlquery.QueryAll(doc, "//ol/li")
	if err != nil {
		panic(err)
	}
	for i, n := range list {
		a := htmlquery.FindOne(n, "//a")
		fmt.Printf("%d %s(%s)\n", i, htmlquery.InnerText(a), htmlquery.SelectAttr(a, "href"))
	}
}
 ~/golang $ go run example.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x6ae4aa]

goroutine 1 [running]:
github.com/antchfx/htmlquery.InnerText.func1(0xc000132ae0, 0x0)
	/home/user/go/src/github.com/antchfx/htmlquery/query.go:148 +0x2a
github.com/antchfx/htmlquery.InnerText(0x0, 0x75b52e, 0x3)
	/home/user/go/src/github.com/antchfx/htmlquery/query.go:161 +0x84
main.main()
	/home/user/golang/example.go:19 +0xc8
exit status 2
go version
go version go1.13.8 linux/amd64

Any hints?

Thanks!

Can't get node by their index

Hello, thanks for great library!

For example, we have some piece of xpath, which give me a valid node when i test in browser:

(//table//tbody)[7]

But if i specify it in library, like:

filePath := "./test.html"

doc, er := htmlquery.LoadDoc(filePath)

if er != nil {
  log.Fatal(er)
}

expr, _ := xpath.Compile("(//table//tbody)[7]")

v := expr.Evaluate(htmlquery.CreateXPathNavigator(doc))

values, ok := v.(*xpath.NodeIterator)

if ok {
	for values.MoveNext() {
		log.Println("Founded value is", values.Current().Value())
	}
}else {
	log.Println("Not node iterator.")
}

The output will be empty, because library not found any node. Soo... My question is simple, do i do something wrong, or it bug in library?

HTML
<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Testing</title>
</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- Show loading image - place at the bottom of the page -->
<div class="modal_loading"></div>
<div style="margin: 0px auto; width: 600px;">
  <table border="0" width="100%" cellspacing="0" cellpadding="0" align="center">
      <tbody>
      <tr>
          <td align="left" width="100%">
              <table border="0" width="100%" height="100">
                  <tbody>
                  <tr>
                      <td align="left" valign="middle" width="150">  <img width="120" src="/logo.png" border="0" /></td>
                      <td>
                          <form name="form2" id="form2" method="post" data-ajax="false">
                              <input type="hidden" name="mode" value="search" />
                              <table border="0" width="100%">
                                  <tbody>
                                  <tr>
                                      <td height="40" colspan="3"></td>
                                  </tr>
                                  <tr>
                                      <td align="center" width="120">Tracking No.</td>
                                      <td align="right" width="220"><input type="text" id="search_no" name="search_no" placeholder="Enter value" maxlength="30" style="height: 44px" onclick="this.select();" /></td>
                                      <td align="right"><button type="submit" id="btnSubmit" style="width: 100px;">Query</button></td>
                                  </tr>
                                  <tr>
                                      <td align="right" width="180" colspan="3"><span id="show_msg_01"></span></td>
                                  </tr>
                                  <tr>
                                      <td align="right" width="180" colspan="3"><span id="tracking_info"></span></td>
                                  </tr>
                                  <tr>
                                      <td align="right" width="180" colspan="3"><span id="contact_info"></span></td>
                                  </tr>

                                  <tr>
                                      <td align="right" height="20" colspan="3">
                                      </td>
                                  </tr>
                                  </tbody>
                              </table>
                          </form>
                      </td>
                  </tr>
                  </tbody>
              </table>
          </td>
      </tr>
      <tr>
          <td width="100%" colspan="2">
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                  <tbody>
                  <tr>
                      <td height="12" width="100%" style="color: #c09853;"></td>
                  </tr>
                  <tr>
                      <td width="100%">
                          <div align="center">
                              <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                  <tbody>
                                  <tr>
                                      <td colspan="4" height="20" width="100%">
                                          <table width="100%" cellspacing="1" cellpadding="3">
                                              <tbody>
                                              <tr height="25">
                                                  <th width="150" align="left">First name:</th>
                                                  <td>First name..</td>
                                              </tr>
                                              <tr height="25">
                                                  <th width="150" align="left">Second:</th>
                                                  <td>Second name..</td>
                                              </tr>
                                              </tbody>
                                          </table>
                                      </td>
                                  </tr>
                                  <tr>
                                      <td height="10" colspan="4"></td>
                                  </tr>
                                  <tr>
                                      <td colspan="4">
                                          <table width="100%" cellspacing="1" cellpadding="3" border="0" bgcolor="#929699">
                                              <tbody>
                                              <tr height="30" align="center" bgcolor="#e0e0e0">
                                                  <th class="text-center" width="5%">No.</th>
                                                  <th class="text-center" width="12%">Date</th>
                                                  <th class="text-center" width="8%">Time</th>
                                                  <th class="text-center" width="8%">Area</th>
                                                  <th class="text-center" width="22%">Status</th>
                                                  <th class="text-center" width="19%">Status(KOR)</th>
                                                  <th class="text-center" width="30%">Remarks</th>
                                                  <!-- 2018.01.22 이승민-------------------------------------- -->
                                                  <!-- ---------------------------------------------------- -->
                                              </tr>
                                              <tr height="50" bgcolor="#FFFFFF" align="center">
                                                  <td style="font-size: 100%;">1</td>
                                                  <td>2021.03.22</td>
                                                  <td>10:22</td>
                                                  <td>Korea</td>
                                                  <td>Oks</td>
                                                  <td>Test</td>
                                                  <td>Some new info</td>
                                              </tr>
                                              </tbody>
                                          </table>
                                      </td>
                                  </tr>
                                  </tbody>
                              </table>
                          </div>
                      </td>
                  </tr>
                  </tbody>
              </table>
          </td>
      </tr>
      </tbody>
  </table>
</div>
</body>

</html>

panic when calling QueryAll with expression starting with $

For example, an xpath query expression of $example causes a panic when calling QueryAll. As far as I can tell, this is an invalid query expression. I'd expect getQuery to return an error when compiling, but instead it looks like it produces an Expr object with a nil query field.

Minimum unit test to reproduce:

package xpathTest

import (
	"strings"
	"testing"
	"github.com/antchfx/htmlquery"
)

func TestLoadInvalidXPath(t *testing.T) {
	reader := strings.NewReader("<html></html>")
	doc, err := htmlquery.Parse(reader)

	if err != nil {
		t.Errorf("Error loading document: %s", err.Error())
		return
	}

	_, err = htmlquery.QueryAll(doc, `$example`)
	if err == nil {
		t.Error("Expected error")
	}
}

Edit: just realised this is probably a problem with the xpath package. Should I raise there instead?

Querying for text() using contains() returns duplicate results

Hello zhengchun,

Thank you for your great library. I'd like to file one issue with text().

Having this simple HTML page

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Test</title>
</head>
<body>
<div>
    <div class="body">
        <strong>We need this.</strong>
        <strong>Not this.</strong>
    </div>
    <strong>And we definitely don't need this.</strong>
</div>
</body>
</html>

I want to extract "We need this." text node. Here's my code:

package main

import (
	"fmt"
	"github.com/antchfx/htmlquery"
	"os"
	"strings"
)

func main() {
	file, err := os.Open("example.html")
	if err != nil {
		panic(err)
	}
	defer file.Close()

	root, err := htmlquery.Parse(file)
	if err != nil {
		panic(err)
	}

	nodes := htmlquery.Find(root, `//div[@class="body"]//text()[contains(.,"need")]`)

	for _, node := range nodes {
		fmt.Println(htmlquery.InnerText(node))
		fmt.Println(strings.Repeat("-", 40))
	}
}

Unfortunately, the result is a bit more than I asked for:


        We need this.
        Not this.
    
----------------------------------------
We need this.
----------------------------------------
We need this.
----------------------------------------

Thank you and stay safe :)

Xpath failing to find nodes

Here's a simple reproducer:

package main

import (
  "fmt"
  "strings"
  "github.com/antchfx/htmlquery"
)

func main(){
        
        str := `<html><head/><body>
<div id="main">
  <table class="generictable" width="100%" border="1" cellpadding="0" cellspacing="0">
    <tr><td class="hidden">XXXX</td></tr>
    <tr class="foo" id="222222"><td class="hidden">1234</td></tr>
  </table>
</div>
</body></html>
`

        tree, _ := htmlquery.Parse(strings.NewReader(str))

        // does not work
        fmt.Println(htmlquery.Find(tree, "//div[@id='main']/table/tr[@class='foo']"))
        // does not work either
        fmt.Println(htmlquery.Find(tree, "//div[@id='main']/table/tr"))
        // does not work either
        fmt.Println(htmlquery.Find(tree, "//table/tr"))
        // works
        fmt.Println(htmlquery.Find(tree, "//tr[@class='foo']"))

}

Output:

[]
[]
[]
[0xc000192620]

This is all pretty basic stuff, and all four Xpath expressions successfully match nodes with python's lxml, for example. Am I doing something wrong?

Xpath position function not working properly

Hi there,

First of all, thank you for the packages, they're very useful 🚀

I've been having issues with the position function and I'm not sure if it's an issue with the htmlquery package or the xpath package, here's an example:

const htmlSample = `<!DOCTYPE html><html lang="en-US">
<head>
<title>Hello,World!</title>
</head>
<body>
<div class="test">
	<a href="/test1">Test 1</a>
</div>
<div class="test">
	<a href="/test2">Test 1</a>
</div>
<div class="test">
	<a href="/test3">Test 1</a>
</div>
</body>
</html>
`

func TestXPath(t *testing.T) {
	list := Find(testDoc, "//div[@class=\"test\" and position()=1]//a/@href")
	for _, n := range list {
		fmt.Println(InnerText(n))
	}
}

I would expect this to filter all the nodes that have the class test and have a position == 1, so only the first <a /> element. But instead, I get all the nodes. If I try position()=2 I get nothing back.

If I instead use this xpath, it gives me the correct element:

//div[@class=\"test\"][2]//a/@href

If I try this on the browser it works, so I'm not sure if it is expected that it works this way here 🤔.

What could be the problem?
Thank you again!

Code example issue on README

Hi!
Thank you for excellent OSS.

I would like to try this library for my personal project.

However, when I tried to use this library along with README,
the following example seemed not working in my environment.
So could you share the correct information?

my environment info is as follows

  • Golang: go version go1.14.2 linux/amd64
  • WSL: Ubuntu 18.04 LTS
//not worked
list := range htmlquery.Find(doc, "//a/@href")	
for n := range list{
	fmt.Println(htmlquery.InnerText(n)) // output @href value without A element.
}
//=> # command-line-arguments
//./main.go:16:34: cannot use n (type int) as type *html.Node in argument to htmlquery.InnerText

//worked
list := htmlquery.Find(doc, "//a@href")
for _, val := range list{
	fmt.Println(htmlquery.InnerText(val))
}
//=>More information...

`Find` returns an element when passed an invalid xpath

package main

import (
	"fmt"
	"strings"

	"github.com/antchfx/htmlquery"
)

const html = `<html>
<body>
<div>
    <ul id="food">
        <li>avocado</li>
    </ul>
</div>
</body>
</html>`

const xpath = `//*[contains(@id,"food")]//*[contains(@id,"food")]//*[contains(text(),"avocado")]`

func main() {
	doc, err := htmlquery.Parse(strings.NewReader(html))
	if err != nil {
		panic(err)
	}

	list := htmlquery.Find(doc, xpath)

	node := list[0]
	fmt.Println(node.Data, node.FirstChild.Data, node.Parent.Data)
}

Hi,

I have an issue with the Find method. When passed an invalid xpath (confirmed by the HTML inspector of Chrome and Firefox), it returns a node.

On playground: https://go.dev/play/p/3Z6jtSNsYfx

Thank you !

text() node function does not work as it should.

Example:

s := "<span class='output'>24<sup>95</sup></span>"
doc, _ := htmlquery.Parse(strings.NewReader(s))
nx, _ := htmlquery.QueryAll(doc, "//span[@class='output']//text()")
for _, n := range nx {
	fmt.Println(htmlquery.InnerText(n))
}

Output:

2495
24
95
95

Expected Output:

24
95

Randomly panics !

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x90f01c]
goroutine 1427 [running]:
github.com/antchfx/htmlquery.(*NodeNavigator).NodeType(0xc0009a0d50?)
/tmp/codon/tmp/cache/go-path/pkg/mod/github.com/antchfx/[email protected]/query.go:213 +0x1c
github.com/antchfx/xpath.axisPredicate.func1({0xbc3040, 0xc000507ef0})
/tmp/codon/tmp/cache/go-path/pkg/mod/github.com/antchfx/[email protected]/build.go:45 +0x47
github.com/antchfx/xpath.(*selfQuery).Select(0xc000507ed8, {0xbbd8e0, 0xc000070d60})
/tmp/codon/tmp/cache/go-path/pkg/mod/github.com/antchfx/[email protected]/query.go:523 +0x65
github.com/antchfx/xpath.(*childQuery).Select(0xc0009a1020, {0xbbd8e0, 0xc000070d60})
/tmp/codon/tmp/cache/go-path/pkg/mod/github.com/antchfx/[email protected]/query.go:181 +0x62
github.com/antchfx/xpath.(*filterQuery).Select(0xc0009a1050, {0xbbd8e0, 0xc000070d60})
/tmp/codon/tmp/cache/go-path/pkg/mod/github.com/antchfx/[email protected]/query.go:578 +0x83
github.com/antchfx/xpath.(*childQuery).Select(0xc0009a1080, {0xbbd8e0, 0xc000070d60}).
/tmp/codon/tmp/cache/go-path/pkg/mod/github.com/antchfx/[email protected]/query.go:181 +0x62
 github.com/antchfx/xpath.(*NodeIterator).MoveNext(0xc000070d60)
 /tmp/codon/tmp/cache/go-path/pkg/mod/github.com/antchfx/[email protected]/xpath.go:86 +0x38
github.com/antchfx/htmlquery.QuerySelector(0x0, 0xc0000b5340)
 /tmp/codon/tmp/cache/go-path/pkg/mod/github.com/antchfx/[email protected]/query.go:73 +0xf5
 github.com/antchfx/htmlquery.Query(0xc000917730?, {0xa485b5?, 0xc000917730?})
 /tmp/codon/tmp/cache/go-path/pkg/mod/github.com/antchfx/[email protected]/query.go:67 +0x47

The library randomly panics killing my whole script, I have no way to reproduce it because its totally random and comes at any time. It comes up when calling the InnerText() method. Please stop it from panicking.

Get a panic when parse html page

Get a fatal panic when executing htmlquery.QueryAll on webpage from url https://baidu.com OR local file baidu.html as below script.
https://github.com/aaronchen2k/deeptest/blob/main/cmd/test/htmlquery_test.go

It works well if use a html string like:
https://github.com/aaronchen2k/deeptest/blob/main/internal/server/modules/v1/helper/mock/html.go

Thanks!

concurrent writes to map panic

it appears positmap in descendantQuery somehow gets reused. I have not been able to find any global state that is the cause but I did manage to make a (unreliable) test case. If I set it to 100 goroutines it pretty reliably triggers it for me, though i've gotten it to trigger with as few as 20 goroutines. It only seems to happen with xpath 1.2.2 but going to htmlquery 1.2.5 seems to make it less likely to happen (though 1.2.5 htmlquery seems to cause hangs). I have never been able to reproduce it with xpath 1.2.1. Attaching testcase with 100 goroutines and a stack trace from a run with 30 (for brevity)
Test case:

package main
import (
	"fmt"
	"strings"
	"sync"
	"github.com/antchfx/htmlquery"
	"golang.org/x/net/html"
)
func main() {
	wg := new(sync.WaitGroup)
	for i := 0; i <= 100; i++ {
		wg.Add(1)
		go func(i int) {
			defer wg.Done()
			fmt.Printf("%d: %#v\n", i, getDiv(`//div`))
		}(i)
	}
	wg.Wait()
}
func getDiv(selector string) []*html.Node {
	s := `<html><head></head><body><div>a</div></body>`
	doc, err := htmlquery.Parse(strings.NewReader(s))
	if err != nil {
		panic(err)
	}
	return htmlquery.Find(doc, selector)
}

stack trace:

fatal error: concurrent map writes
12: []*html.Node{(*html.Node)(0x140002816c0)}
22: []*html.Node{(*html.Node)(0x140003941c0)}
1: []*html.Node{(*html.Node)(0x1400031c700)}
11: []*html.Node{(*html.Node)(0x1400041c1c0)}
goroutine 47 [running]:
[github.com/antchfx/xpath.(*descendantQuery).Select.func1()](http://github.com/antchfx/xpath.(*descendantQuery).Select.func1())
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/query.go:267 +0xe8
[github.com/antchfx/xpath.(*descendantQuery).Select(0x1400013a240](http://github.com/antchfx/xpath.(*descendantQuery).Select(0x1400013a240), {0x104739ea8, 0x1400008e120})
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/query.go:289 +0x160
[github.com/antchfx/xpath.(*NodeIterator).MoveNext(0x1400008e120)](http://github.com/antchfx/xpath.(*NodeIterator).MoveNext(0x1400008e120))
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/xpath.go:86 +0x3c
[github.com/antchfx/htmlquery.QuerySelectorAll(0x140000947e0](http://github.com/antchfx/htmlquery.QuerySelectorAll(0x140000947e0), 0x140001581c0)
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/query.go:83 +0x120
[github.com/antchfx/htmlquery.QueryAll(0x10473a188](http://github.com/antchfx/htmlquery.QueryAll(0x10473a188)?, {0x10468e778?, 0x0?})
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/query.go:54 +0x5c
[github.com/antchfx/htmlquery.Find(...)](http://github.com/antchfx/htmlquery.Find(...))
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/query.go:30
main.getDiv({0x10468e778, 0x5})
	/tmp/xpath/main.go:30 +0x74
main.main.func1(0x0?)
	/tmp/xpath/main.go:18 +0x60
created by main.main
	/tmp/xpath/main.go:16 +0x3c
goroutine 1 [semacquire]:
sync.runtime_Semacquire(0x140000021a0?)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/runtime/sema.go:62 +0x28
sync.(*WaitGroup).Wait(0x1400012e2c0)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/sync/waitgroup.go:139 +0x80
main.main()
	/tmp/xpath/main.go:21 +0xf0
goroutine 19 [runnable]:
internal/poll.runtime_Semrelease(0x2d?)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/runtime/sema.go:82 +0x24
internal/poll.(*fdMutex).rwunlock(0x14000317d78?, 0x28?)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_mutex.go:188 +0xcc
internal/poll.(*FD).writeUnlock(0x1400012c060)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_mutex.go:249 +0x28
internal/poll.(*FD).Write(0x1400012c060, {0x1400032c000, 0x2d, 0x40})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_unix.go:388 +0x368
os.(*File).write(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/os/file_posix.go:48
os.(*File).Write(0x1400012a008, {0x1400032c000?, 0x2d, 0x14000317f80?})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/os/file.go:176 +0x60
fmt.Fprintf({0x10473a0e8, 0x1400012a008}, {0x1046911f2, 0x8}, {0x14000317f80, 0x2, 0x2})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/fmt/print.go:205 +0x84
fmt.Printf(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/fmt/print.go:213
main.main.func1(0x0?)
	/tmp/xpath/main.go:18 +0xdc
created by main.main
	/tmp/xpath/main.go:16 +0x3c
goroutine 30 [runnable]:
syscall.syscall(0x14000416d78?, 0x1045c1c28?, 0x80000000000?, 0x7ffff80000000000?)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/runtime/sys_darwin.go:23 +0x54
syscall.write(0x1400012c060?, {0x1400042c000?, 0x14000416e98?, 0x1045c7844?})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/syscall/zsyscall_darwin_arm64.go:1653 +0x48
syscall.Write(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/syscall/syscall_unix.go:211
internal/poll.ignoringEINTRIO(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_unix.go:794
internal/poll.(*FD).Write(0x1400012c060?, {0x1400042c000?, 0x2e?, 0x40?})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_unix.go:383 +0x2ac
os.(*File).write(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/os/file_posix.go:48
os.(*File).Write(0x1400012a008, {0x1400042c000?, 0x2e, 0x14000416f80?})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/os/file.go:176 +0x60
fmt.Fprintf({0x10473a0e8, 0x1400012a008}, {0x1046911f2, 0x8}, {0x14000416f80, 0x2, 0x2})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/fmt/print.go:205 +0x84
fmt.Printf(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/fmt/print.go:213
main.main.func1(0x0?)
	/tmp/xpath/main.go:18 +0xdc
created by main.main
	/tmp/xpath/main.go:16 +0x3c
goroutine 35 [runnable]:
internal/poll.runtime_Semacquire(0x14000205d78?)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/runtime/sema.go:67 +0x28
internal/poll.(*fdMutex).rwlock(0x1400012c060, 0xa8?)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_mutex.go:154 +0xe0
internal/poll.(*FD).writeLock(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_mutex.go:239
internal/poll.(*FD).Write(0x1400012c060, {0x14000132140, 0x2e, 0x40})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_unix.go:370 +0x48
os.(*File).write(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/os/file_posix.go:48
os.(*File).Write(0x1400012a008, {0x14000132140?, 0x2e, 0x14000205f80?})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/os/file.go:176 +0x60
fmt.Fprintf({0x10473a0e8, 0x1400012a008}, {0x1046911f2, 0x8}, {0x14000205f80, 0x2, 0x2})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/fmt/print.go:205 +0x84
fmt.Printf(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/fmt/print.go:213
main.main.func1(0x0?)
	/tmp/xpath/main.go:18 +0xdc
created by main.main
	/tmp/xpath/main.go:16 +0x3c
goroutine 40 [semacquire]:
internal/poll.runtime_Semacquire(0x14000204d78?)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/runtime/sema.go:67 +0x28
internal/poll.(*fdMutex).rwlock(0x1400012c060, 0xa8?)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_mutex.go:154 +0xe0
internal/poll.(*FD).writeLock(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_mutex.go:239
internal/poll.(*FD).Write(0x1400012c060, {0x1400028a000, 0x2e, 0x80})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_unix.go:370 +0x48
os.(*File).write(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/os/file_posix.go:48
os.(*File).Write(0x1400012a008, {0x1400028a000?, 0x2e, 0x14000204f80?})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/os/file.go:176 +0x60
fmt.Fprintf({0x10473a0e8, 0x1400012a008}, {0x1046911f2, 0x8}, {0x14000204f80, 0x2, 0x2})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/fmt/print.go:205 +0x84
fmt.Printf(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/fmt/print.go:213
main.main.func1(0x0?)
	/tmp/xpath/main.go:18 +0xdc
created by main.main
	/tmp/xpath/main.go:16 +0x3c
goroutine 46 [runnable]:
[github.com/antchfx/htmlquery.(*NodeNavigator).MoveToRoot(0x14000124a20?)](http://github.com/antchfx/htmlquery.(*NodeNavigator).MoveToRoot(0x14000124a20?))
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/query.go:263 +0x54
[github.com/antchfx/xpath.(*contextQuery).Select(0x1400012e2d0](http://github.com/antchfx/xpath.(*contextQuery).Select(0x1400012e2d0), {0x104739ea8?, 0x14000158500?})
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/query.go:47 +0x78
[github.com/antchfx/xpath.(*descendantQuery).Select(0x1400013a240](http://github.com/antchfx/xpath.(*descendantQuery).Select(0x1400013a240), {0x104739ea8, 0x14000158500})
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/query.go:246 +0x54
[github.com/antchfx/xpath.(*NodeIterator).MoveNext(0x14000158500)](http://github.com/antchfx/xpath.(*NodeIterator).MoveNext(0x14000158500))
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/xpath.go:86 +0x3c
[github.com/antchfx/htmlquery.QuerySelectorAll(0x140001d2fc0](http://github.com/antchfx/htmlquery.QuerySelectorAll(0x140001d2fc0), 0x140001581c0)
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/query.go:83 +0x120
[github.com/antchfx/htmlquery.QueryAll(0x10473a188](http://github.com/antchfx/htmlquery.QueryAll(0x10473a188)?, {0x10468e778?, 0x0?})
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/query.go:54 +0x5c
[github.com/antchfx/htmlquery.Find(...)](http://github.com/antchfx/htmlquery.Find(...))
	/Users/jacobalberty/go/pkg/mod/github.com/antchfx/[email protected]/query.go:30
main.getDiv({0x10468e778, 0x5})
	/tmp/xpath/main.go:30 +0x74
main.main.func1(0x0?)
	/tmp/xpath/main.go:18 +0x60
created by main.main
	/tmp/xpath/main.go:16 +0x3c
goroutine 48 [runnable]:
internal/poll.runtime_Semacquire(0x14000209d78?)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/runtime/sema.go:67 +0x28
internal/poll.(*fdMutex).rwlock(0x1400012c060, 0xa8?)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_mutex.go:154 +0xe0
internal/poll.(*FD).writeLock(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_mutex.go:239
internal/poll.(*FD).Write(0x1400012c060, {0x14000132180, 0x2e, 0x40})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/internal/poll/fd_unix.go:370 +0x48
os.(*File).write(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/os/file_posix.go:48
os.(*File).Write(0x1400012a008, {0x14000132180?, 0x2e, 0x14000209f80?})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/os/file.go:176 +0x60
fmt.Fprintf({0x10473a0e8, 0x1400012a008}, {0x1046911f2, 0x8}, {0x14000209f80, 0x2, 0x2})
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/fmt/print.go:205 +0x84
fmt.Printf(...)
	/opt/homebrew/Cellar/go/1.19.5/libexec/src/fmt/print.go:213
main.main.func1(0x0?)
	/tmp/xpath/main.go:18 +0xdc
created by main.main
	/tmp/xpath/main.go:16 +0x3c
exit status 2

Access inner text from node with other elements around

I want to access the inner text " bar" from the node '<code>' which also has some '<span>' elements inside

<html>
  <body>
    <pre>
        <code>
            <span>foo</span>
            <span>:</span> bar <!-- <<<< target -->
            <span>;</span>
        </code>
    </pre>
  </body>
</html>
doc, err := htmlquery.LoadDoc(file)
if err != nil {
    return err
}
node := htmlquery.FindOne(doc, "html/body/pre/code")

fmt.Println(htmlquery.InnerText(node))

Actual result: "foo: bar;"
Expected: "bar"

For some reason the span's inner texts are also included.. how can I prevent this?

Tried it with this path tester extendsclass.com/xpath-tester with the query "//body/pre/code/text()" and it returns the expected value

Any ideas?

Remove a `FindEach()` and `FindEachWithBreak()` method

FindEach and FindEachWithBreak will duplicate invoke a callback function if an XPath expression matches duplicate elements, see #6, the other reason it‘s often not used. I planing remove these method from package, if you still want it, you can implement yourself method.

[Runtime error] - invalid memory address or nil pointer dereference

Screen Shot 2020-05-07 at 12 48 04 PM

How to replicate

XPath := "//*[@id=\"market-summary\"]/div[2]/div/div[1]/div[1]"

doc, err := htmlquery.LoadURL("https://stockx.com/air-jordan-1-retro-high-off-white-university-blue")
if err != nil {
panic(err)
}

s2 := htmlquery.FindOne(doc, XPath)

p := string(htmlquery.InnerText(s2))

return p

FindOne with expression containing groups only works the first time

If I do an expression like (//*/div) it works the first time but subsequent calls with the same expression return nil. They always return the same result however if i simply drop the paranthesis. This is problematic because I need the paranthesis do pick an element by its index (//*/div)[1]. This seems to have been introduced in the fix for #42 which was done in version 1.2.0 of the xpath library that htmlquery uses.
Here's a sample piece of code where it fails.

package main

import (
	"fmt"
	"strings"

	"github.com/antchfx/htmlquery"
	"golang.org/x/net/html"
)

func main() {
	fmt.Printf("Run 1: %#v\n", getDiv(`(//*/div)`)) // works
	fmt.Printf("Run 2: %#v\n", getDiv(`(//*/div)`)) // fails

	fmt.Printf("Run 1: %#v\n", getDiv(`//*/div`)) // works
	fmt.Printf("Run 2: %#v\n", getDiv(`//*/div`)) // also works
}

func getDiv(selector string) *html.Node {
	s := `<html><head></head><body><div>a</div></body>`
	doc, err := htmlquery.Parse(strings.NewReader(s))
	if err != nil {
		panic(err)
	}
	return htmlquery.FindOne(doc, selector)
}

Switch to SemVer

Hello.
I'm started using Colly but your library changed the interface.
It will good to switch htmlquery to SemVer to avoid this in future

This is the reason gocolly/colly#282

Thank you

i am grabbing form from a html page but this is also printing some garbage string "0xc000145ea0"

&{0xc000144f50 0xc0001451f0 0xc0001452d0 3 input input [{ type email} { name email} { class form-control unicase-form-control text-input} { id exampleInputEmail1}]}
&{0xc0001453b0 0xc000145650 0xc000145730 3 input input [{ type password} { name password} { class form-control unicase-form-control text-input} { id exampleInputPassword1}]}
&{0xc000145ea0 0xc0001462a0 0xc000147ab0 0xc0001461c0 0xc000147b20 3 form form [{ class register-form outer-top-xs} { role form} { method post} { name register} { onsubmit return valid();}]}
&{0xc000146310 0xc0001465b0 0xc000146690 3 input input [{ type text} { class form-control unicase-form-control text-input} { id fullname} { name fullname} { required required}]}
&{0xc000146770 0xc000146a10 0xc000146af0 3 input input [{ type email} { class form-control unicase-form-control text-input} { id email} { onblur userAvailability()} { name emailid} { required }]}
&{0xc000146cb0 0xc000146f50 0xc000147030 3 input input [{ type text} { class form-control unicase-form-control text-input} { id contactno} { name contactno} { maxlength 10} { required }]}
&{0xc000147110 0xc0001473b0 0xc000147490 3 input input [{ type password} { class form-control unicase-form-control text-input} { id password} { name password} { required }]}
&{0xc000147570 0xc000147810 0xc0001478f0 3 input input [{ type password} { class form-control unicase-form-control text-input} { id confirmpassword} { name confirmpassword} { required }]}

substring-after() is not being executed

I tried a few expressions with substring-after() and it seems the functions is not being executed at all. Tried to debug func.go and substringIndFunc is being called, returns a callable which is never called though.

Example expression:
substring-after(//span[@Class="pageNumbersInfo"]//text(), "of ")
Node: Pages 1 of 25

Searx xpath doesn't work with htmlquery

Hello, I'm trying to extract Google's data using Searx's xpath variables, but they only work for some and not all.

These are the xpaths they use:

results_xpath = '//div[contains(@class, "ZINbbc")]'
url_xpath = './/div[@class="kCrYT"][1]/a/@href'
title_xpath = './/div[@class="kCrYT"][1]/a/div[1]'
content_xpath = './/div[@class="kCrYT"][2]//div[contains(@class, "BNeawe")]//div[contains(@class, "BNeawe")]'
suggestion_xpath = '//div[contains(@class, "ZINbbc")][last()]//div[@class="rVLSBd"]/a//div[contains(@class, "BNeawe")]'
spelling_suggestion_xpath = '//div[@id="scc"]//a'

I made this simple program to test:

package main

import (
	"fmt"

	"github.com/antchfx/htmlquery"
)

func main() {
	doc, err := htmlquery.LoadDoc("test.html")
	if err != nil {
		panic(err)
	}
	results := htmlquery.Find(doc, "//div[contains(@class, \"ZINbbc\")]")
	for _, result := range results {
		title := htmlquery.FindOne(result, "//div[@class=\"kCrYT\"][1]/a/div[1]")
		if title != nil {
			fmt.Println("\ntitle", htmlquery.InnerText(title))
		}
		url := htmlquery.FindOne(result, "//div[@class=\"kCrYT\"][1]/a/@href")
		if url != nil {
			fmt.Println("url:", htmlquery.InnerText(url))
		}
		content := htmlquery.FindOne(result, "//div[@class=\"kCrYT\"][2]//div[contains(@class, \"BNeawe\")]//div[contains(@class, \"BNeawe\")]")
		if content != nil {
			fmt.Println("content:", htmlquery.InnerText(content))
		}
	}
}

The title and url xpaths works, but the content xpath does not.

This is the content of the text.html file:

<!doctype html><html lang="en-NL"><head><meta charset="UTF-8"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>bill gates - Google Search</title><script nonce="sy4xAKW0KNvcEZLmwf6uxQ==">(function(){
  document.documentElement.addEventListener("submit",function(b){var a;if(a=b.target){var c=a.getAttribute("data-submitfalse");a="1"==c||"q"==c&&!a.elements.q.value?!0:!1}else a=!1;a&&(b.preventDefault(),b.stopPropagation())},!0);document.documentElement.addEventListener("click",function(b){var a;a:{for(a=b.target;a&&a!=document.documentElement;a=a.parentElement)if("A"==a.tagName){a="1"==a.getAttribute("data-nohref");break a}a=!1}a&&b.preventDefault()},!0);}).call(this);(function(){
  var a=window.performance;window.start=Date.now();a:{var b=window;if(a){var c=a.timing;if(c){var d=c.navigationStart,f=c.responseStart;if(f>d&&f<=window.start){window.start=f;b.wsrt=f-d;break a}}a.now&&(b.wsrt=Math.floor(a.now()))}}window.google=window.google||{};var h=function(g){g&&g.target.setAttribute("data-iml",Date.now())};document.documentElement.addEventListener("load",h,!0);google.rglh=function(){document.documentElement.removeEventListener("load",h,!0)};}).call(this);(function(){window.google.erd={sp:'srp',jsr:100,bv:229};var e=0,f,g=google.erd,k=g.jsr;google.ml=function(b,d,c,h){google.dl&&(google.dl(b,c),e++);if(0>k){window.console&&console.error(b,c);if(-2==k)throw b;var a=!1}else a=!b||!b.message||"Error loading script"==b.message||1<=e&&!h?!1:!0;if(!a)return null;e++;d&&(f=b&&b.message);d=c||{};c=encodeURIComponent;a="/gen_204?atyp=i&ei="+c(google.kEI);google.kEXPI&&(a+="&jexpid="+c(google.kEXPI));a+="&srcpg="+c(g.sp)+"&jsr="+c(g.jsr)+"&bver="+c(g.bv);for(var l in d)a+="&",a+=c(l),a+="=",a+=c(d[l]);a=a+"&emsg="+c(b.name+": "+b.message);a=a+
  "&jsst="+c(b.stack||"N/A");12288<=a.length&&(a=a.substr(0,12288));b=a;h||google.log(0,"",b);return b};window.onerror=function(b,d,c,h,a){f!==b&&google.ml(a instanceof Error?a:Error(b),!1);f=null;1<=e&&(window.onerror=null)};})();(function(){var gbvu='/search?q\x3dbill+gates\x26lr\x3dlang_en\x26hl\x3den\x26ie\x3dUTF-8\x26tbs\x3dlr:lang_1en\x26gbv\x3d2\x26sei\x3dAWGfXpnLNoWIlwSCz4zYCA';(function(){
  var e=function(c,a){this.a=c===b&&a||"";this.g=d};e.prototype.i=!0;e.prototype.h=function(){return this.a.toString()};var f=/^(?:(?:https?|mailto|ftp):|[^:/?#]*(?:[/?#]|$))/i,d={},b={};var g,h="1";if(document&&document.getElementById)if("undefined"!=typeof XMLHttpRequest)h="2";else if("undefined"!=typeof ActiveXObject){var k,l,m=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"];for(k=0;l=m[k++];)try{new ActiveXObject(l);h="2";break}catch(c){}}g=h;if("2"==g&&-1==location.search.indexOf("&gbv=2")){var n=gbvu,p=document.getElementById("gbv");p&&(p.value=g);n&&window.setTimeout(function(){var c=location;if(n instanceof e)var a=n;else a=n,a instanceof e||(a="object"==typeof a&&a.i?a.h():String(a),f.test(a)||(a="about:invalid#zClosurez"),a=new e(b,a));c.href=a instanceof e&&a.constructor===e&&a.g===d?a.a:"type_error:SafeUrl"},0)};}).call(this);})();</script><style>body{margin:0 auto;max-width:736px;padding:0 8px}a{color:#1967D2;text-decoration:none;tap-highlight-color:rgba(0,0,0,.1)}a:visited{color:#4B11A8}a:hover{text-decoration:underline}img{border:0}html{font-family:Roboto,HelveticaNeue,Arial,sans-serif;font-size:14px;line-height:20px;text-size-adjust:100%;color:#3C4043;word-wrap:break-word;background-color:#fff}.bRsWnc{background-color:#fff;border-top:1px solid #e0e0e0;height:39px;overflow:hidden}.N6RWV{height:51px;overflow-scrolling:touch;overflow-x:auto;overflow-y:hidden}.Uv67qb{box-pack:justify;font-size:12px;line-height:37px;justify-content:space-between;justify-content:space-between}.Uv67qb a,.Uv67qb span{color:#757575;display:block;flex:none;padding:0 16px;text-align:center;text-transform:uppercase;}span.OXXup{border-bottom:2px solid #4285f4;color:#4285f4;font-weight:bold}a.eZt8xd:visited{color:#757575}.FElbsf{border-left:1px solid rgba(0,0,0,.12)}header article{overflow:visible}.Pg70bf{height:39px;display:box;display:flex;display:flex;width:100%}.H0PQec{position:relative;flex:1}.sbc{display:flex;width:100%}.Pg70bf input{margin:2px 4px 2px 8px;}.x{width:26px;color:#757575;font:27px/38px arial, sans-serif;line-height:40px;}#qdClwb{flex:0 0 auto;width:39px;height:39px;border-bottom:0;padding:0;border-top-right-radius:8px;background-color:#3b78e7;border:1px solid #3367d6;background-image:url(data:image/gif;base64,R0lGODdhJAAjAPIHAODr/nCk+MPZ/FmV96zK+/7+/5K5+kqL9iwAAAAAJAAjAEADani63P4wykmbKcQRXDscQAEMXmmeaLQVLCukzyC09AjfeK7v/MAajACLhPMVAgwjsUcEiZa8xgAYrVqv2Kx2iwsIAAABknfBBAKrTE4IcMyot8ur8datqIbQfJdnAfo2WE6BV05wXIiJigkAOw==);}.sc{font-size:;position:absolute;top:39px;left:0;right:0;box-shadow:0px 2px 5px rgba(0,0,0,.2);z-index:2;background-color:#fff}.sc>div{padding:10px 10px;padding-left:16px;padding-left:14px;border-top:1px solid #DFE1E5}.scs{background-color:#f5f5f5;}.noHIxc{display:block;font-size:16px;padding:0 0 0 8px;flex:1;height:35px;outline:none;border:none;width:100%;-webkit-tap-highlight-color:rgba(0,0,0,0);overflow:hidden;}.sbc input[type=text]{background:none}.sml .cOl4Id{display:none}.l{display:none}.sml header{background:none}.sml .l{display:block;padding:0 8px}.sml .l{letter-spacing:-1px;text-align:center;border-radius:2px 0 0 0;font:22px/36px Futura, Arial, sans-serif;font-smoothing:antialiased}.bz1lBb{background:#fff;border-radius:8px 8px 0 0;box-shadow:0 1px 6px rgba(32, 33, 36, 0.18);margin-top:10px}.KP7LCb{border-radius:0 0 8px 8px;box-shadow:0 2px 3px rgba(32, 33, 36, 0.18);margin-bottom:10px;overflow:hidden}.cOl4Id{letter-spacing:-1px;text-align:center;font:22pt Futura, Arial, sans-serif;padding:10px 0 5px 0;height:37px;font-smoothing:antialiased}.cOl4Id span{display:inline-block}.S591j{height:100%}.V6gwVd{color:#4285f4}.iWkuvd{color:#ea4335}.cDrQ7{color:#fbcc05}.ntlR9{color:#34a853}.tJ3Myc{-webkit-transform:rotate(-20deg);position:relative;left:-1px;display:inline-block}footer{text-align:center;margin-top:18px}footer a,footer a:visited,.smiUbb{color:#5f6368}.ksTU4c{margin:0 13px}#mCljob{margin-top:36px}#mCljob>div{margin:20px}</style></head><body jsmodel=" TvHxbe"><header id="hdr"><script nonce="sy4xAKW0KNvcEZLmwf6uxQ==">(function(){var c=500;(function(){window.screen&&window.screen.width<=c&&window.screen.height<=c&&document.getElementById("hdr").classList.add("sml");}).call(this);})();</script><div class="cOl4Id"><a href="/?sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQOwgC"><span class="V6gwVd">G</span><span class="iWkuvd">o</span><span class="cDrQ7">o</span><span class="V6gwVd">g</span><span class="ntlR9">l</span><span class="iWkuvd tJ3Myc">e</span></a></div><div class="bz1lBb"><form class="Pg70bf" id="sf"><a class="l" href="/?lr=lang_en&amp;gbv=1&amp;hl=en&amp;output=search&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQPAgE"><span class="V6gwVd">G</span><span class="iWkuvd">o</span><span class="cDrQ7">o</span><span class="V6gwVd">g</span><span class="ntlR9">l</span><span class="iWkuvd tJ3Myc">e</span></a><input name="lr" value="lang_en" type="hidden"><input name="gbv" value="1" type="hidden"><input name="hl" value="en" type="hidden"><input name="ie" value="ISO-8859-1" type="hidden"><input name="tbs" value="lr:lang_1en" type="hidden"><div class="H0PQec"><div class="sbc esbc"><input class="noHIxc" value="bill gates" autocapitalize="none" autocomplete="off" name="q" spellcheck="false" type="text"><input name="oq" type="hidden"><input name="aqs" type="hidden"><div class="sc"></div></div></div><button id="qdClwb" type="submit"></button></form></div></header><div id="main"><div><div class="KP7LCb"> <div class="bRsWnc"> <div class="N6RWV"> <div class="Pg70bf Uv67qb"> <span class="OXXup">All</span><a class="eZt8xd" href="/search?q=bill+gates&amp;lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;source=lnms&amp;tbm=isch&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ_AUICCgB">Images</a><a class="eZt8xd" href="/search?q=bill+gates&amp;lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;source=lnms&amp;tbm=nws&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ_AUICSgC">News</a><a class="eZt8xd" href="/search?q=bill+gates&amp;lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;source=lnms&amp;tbm=vid&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ_AUICigD">Videos</a>  <a href="https://maps.google.com/maps?q=bill+gates&amp;gws_rd=cr&amp;gbv=1&amp;lr=lang_en&amp;hl=en&amp;um=1&amp;ie=UTF-8&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ_AUICygE">Maps</a>  <a href="/search?q=bill+gates&amp;lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;source=lnms&amp;tbm=shop&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ_AUIDCgF">Shopping</a>  <a href="/search?q=bill+gates&amp;lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;source=lnms&amp;tbm=bks&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ_AUIDSgG">Books</a>  <div class="FElbsf"><a href="/advanced_search" style="white-space:nowrap" id="st-toggle" role="button">Search tools</a></div> </div> </div> </div> </div><div class="Pg70bf wEsjbd ZINbbc xpd O9g5cc uUPGi" id="st-card"><style>.wEsjbd{background-color:#fff;height:44px;white-space:nowrap}.coPU8c{height:60px;overflow-scrolling:touch;overflow-x:auto;overflow-y:hidden}.Xj2aue{height:44px;overflow:hidden}.RnNGze{margin:11px 16px}.wEsjbd div,.wEsjbd a,.wEsjbd li{outline-width:0;outline:none}</style><div class="Xj2aue"><div class="coPU8c"><div class="RnNGze"><style>.PA9J5{display:inline-block}.RXaOfd{display:inline-block;height:22px;position:relative;padding-top:0;padding-bottom:0;padding-right:16px;padding-left:0;line-height:22px;cursor:pointer;text-transform:uppercase;font-size:12px;color:#757575}.sa1toc{display:none;position:absolute;background:#fff;border:1px solid #d6d6d6;box-shadow:0 2px 4px rgba(0,0,0,0.3);margin:0;white-space:nowrap;z-index:103;line-height:17px;padding-top:5px;padding-bottom:5px;padding-left:0px}.PA9J5:hover .sa1toc{display:block}.mGSy8d a:active,.RXaOfd:active{color:#4285f4}</style><div class="PA9J5"><div class="RXaOfd vQYuGf" role="button" tabindex="0"><style>.TWMOUc{display:inline-block;padding-right:14px;white-space:nowrap}.vQYuGf{font-weight:bold}.OmTIzf{border-color:#909090 transparent;border-style:solid;border-width:4px 4px 0 4px;width:0;height:0;margin-left:-10px;top:50%;margin-top:-2px;position:absolute}.RXaOfd:active .OmTIzf{border-color:#4285f4 transparent}</style><div class="TWMOUc">Search English pages</div><span class="OmTIzf"></span></div><ul class="sa1toc ozatM"><style>.ozatM{font-size:12px;text-transform:uppercase}.ozatM .yNFsl,.ozatM li{list-style-type:none;list-style-position:outside;list-style-image:none}.yNFsl.SkUj4c,.yNFsl a{color:rgba(0,0,0,0.54);text-decoration:none;padding:6px 44px 6px 14px;line-height:17px;display:block}.SkUj4c{background-image:url(//ssl.gstatic.com/ui/v1/menu/checkmark2.png);background-position:right center;background-repeat:no-repeat}.SkUj4c:active{background-color:#f5f5f5}</style><li class="yNFsl"><a href="/search?q=bill+gates&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbas=0&amp;source=lnt&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQpwUIDg">Any language</a></li><li class="yNFsl SkUj4c">Search English pages</li></ul></div><div class="PA9J5"><div class="RXaOfd" role="button" tabindex="0"><div class="TWMOUc">Any time</div><span class="OmTIzf"></span></div><ul class="sa1toc ozatM"><li class="yNFsl SkUj4c">Any time</li><li class="yNFsl"><a href="/search?q=bill+gates&amp;lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en,qdr:h&amp;source=lnt&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQpwUIEQ">Past hour</a></li><li class="yNFsl"><a href="/search?q=bill+gates&amp;lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en,qdr:d&amp;source=lnt&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQpwUIEg">Past 24 hours</a></li><li class="yNFsl"><a href="/search?q=bill+gates&amp;lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en,qdr:w&amp;source=lnt&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQpwUIEw">Past week</a></li><li class="yNFsl"><a href="/search?q=bill+gates&amp;lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en,qdr:m&amp;source=lnt&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQpwUIFA">Past month</a></li><li class="yNFsl"><a href="/search?q=bill+gates&amp;lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en,qdr:y&amp;source=lnt&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQpwUIFQ">Past year</a></li></ul></div><div class="PA9J5"><div class="RXaOfd" role="button" tabindex="0"><div class="TWMOUc">All results</div><span class="OmTIzf"></span></div><ul class="sa1toc ozatM"><li class="yNFsl SkUj4c">All results</li><li class="yNFsl"><a href="/search?q=bill+gates&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=li:1&amp;source=lnt&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQpwUIFw">Verbatim</a></li></ul></div></div></div></div><script nonce="sy4xAKW0KNvcEZLmwf6uxQ==">(function(){
  var a=document.getElementById("st-toggle"),b=document.getElementById("st-card");a&&b&&a.addEventListener("click",function(c){b.style.display=b.style.display?"":"none";c.preventDefault()},!1);}).call(this);</script></div></div><style>.ZINbbc{background-color:#fff;margin-bottom:10px;box-shadow:0 1px 6px rgba(32, 33, 36, 0.28);border-radius:8px}.uUPGi{font-size:14px;line-height:20px;}.O9g5cc>*:first-child{border-top-left-radius:8px;border-top-right-radius:8px}.O9g5cc>*:last-child{border-bottom-left-radius:8px;border-bottom-right-radius:8px}.O9g5cc>.qxDOhb>*:first-child{border-top-left-radius:8px;border-top-right-radius:8px}.O9g5cc>.qxDOhb>*:last-child{border-bottom-left-radius:8px;border-bottom-right-radius:8px}.nGphre{float:right;padding-left:16px}.UykT9d{border-radius:8px;display:block}.nYT7Qb{clear:both}.kCrYT{padding:12px 16px 12px}.BNeawe{white-space:pre-line;word-wrap:break-word}.deIvCb{font-size:16px;line-height:20px;font-weight:400}.deIvCb.HrGdeb{color:rgba(255,255,255,1)}.deIvCb.AP7Wnd{color:#202124}.tAd8D{font-size:14px;line-height:20px}.tAd8D.HrGdeb{color:rgba(255,255,255,.7)}.tAd8D.AP7Wnd{color:#70757A}a.fdYsqf{color:#4B11A8}.r0bn4c.tr0dw{color:rgba(255,255,255,.7)}.r0bn4c.rQMQod{color:#70757A}.Xdlr0d{overflow-x:auto;-webkit-overflow-scrolling:touch;margin:0 -8px;padding:16px 0 16px 24px;padding-top:2px;margin-top:-2px;transform:translate3d(0,0,0)}.idg8be{display:table;border-collapse:separate;border-spacing:8px 0;margin:0 -8px;padding-right:16px}.BVG0Nb{display:table-cell;vertical-align:top;background-color:#fff;border-radius:8px;box-shadow:0 1px 6px rgba(32, 33, 36, 0.28);overflow:hidden}.WddBJd{display:block;margin:0 auto}.R0jTRc{vertical-align:middle}.mHhylf{display:table-cell;vertical-align:middle}.WZ5GJf{align-items:center;padding:0 20px;min-width:112px}.qN9Ked,.DXk5Me{margin:0 auto}.DXk5Me{margin-bottom:12px}.Qi9Fd{background:#fff;border:0;border-radius:999px;display:block;height:56px;justify-content:center;width:56px;z-index:0}.Qi9Fd{box-shadow:0 1px 6px rgba(32, 33, 36, 0.28),inset 0 0 0 0 rgba(0,0,0,0.10),inset 0 0 0 0 rgba(255,255,255,0.50)}.Qi9Fd:focus{outline:none}.Qi9Fd .hWHuJ{display:block;margin:0 auto}.ji5jpf{text-align:center}.skVgpb{display:table;table-layout:fixed;width:100%}.VGHMXd{display:table-cell;vertical-align:middle;height:52px;text-align:center}.LpaDrb{margin:0 auto 8px;display:block}.vbShOe{padding-top:0}.x54gtf{height:1px;background-color:#dfe1e5;margin:0 16px}.Q0HXG{height:1px;background-color:#dfe1e5}.Ap5OSd{padding-bottom:12px}.s3v9rd{font-size:14px;line-height:20px}.s3v9rd.HrGdeb{color:rgba(255,255,255,1)}.s3v9rd.AP7Wnd{color:#202124}.XLloXe{color:#1967D2;font-size:14px;line-height:20px}.XLloXe a:visited{color:#4B11A8}.XLloXe.HrGdeb{color:rgba(255,255,255,1)}.XLloXe.HrGdeb a:visited{color:rgba(255,255,255,.7)}.AVsepf{padding-bottom:8px}.AVsepf.u2x1Od{padding-bottom:0}.Ru8idb{margin-top:-16px}.punez{font-weight:700;letter-spacing:0.75px;text-transform:uppercase}.wyrwXc{font-size:12px;line-height:16px}.wyrwXc.HrGdeb{color:rgba(255,255,255,1)}.wyrwXc.AP7Wnd{color:#202124}.EYOsld{display:inline-block;position:relative}.BFi9Zb{overflow:hidden;position:relative}.S7Jdze{align-items:center;display:flex;flex-direction:column;justify-content:space-around}.FCUp0c{font-weight:bold}.Xb5VRe{color:#1967D2}a:visited .Xb5VRe{color:#4B11A8}.Xb5VRe.tr0dw{color:rgba(255,255,255,1)}a:visited .Xb5VRe.tr0dw{color:rgba(255,255,255,.7)}.wITvVb{margin:0;padding:12px 16px 12px}.LKSyXe{height:1px;background-color:#dfe1e5;margin:0 16px}.BxVv8d{padding:14px}.M56Nqc{padding:0 16px 12px}.Z8j5ae>div>div{border-radius:8px;box-shadow:none;border:1px solid #dfe1e5;margin-bottom:0}.oTWEpb{padding-top:12px}.n1Qedd{overflow:hidden;text-align:center}.KMAGC{margin:0 auto;display:block}.ho0sdc{margin:0 -50%;display:inline-block}.vvjwJb{color:#1967D2;font-size:16px;line-height:20px}.vvjwJb a:visited{color:#4B11A8}.vvjwJb.HrGdeb{color:rgba(255,255,255,1)}.vvjwJb.HrGdeb a:visited{color:rgba(255,255,255,.7)}.UPmit{font-size:14px;line-height:20px}.UPmit.HrGdeb{color:rgba(255,255,255,.7)}.UPmit.AP7Wnd{color:rgba(0,102,33,1)}.PDHNXc{display:table;width:100%;padding-top:16px;padding-bottom:16px;margin-bottom:-12px}.iU269d{display:table-cell;vertical-align:top}.TeHtNe{vertical-align:middle}.kXUfPb{color:#3C4043;font-size:14px;text-align:center}.Vp9uZ{display:block;white-space:pre-line;word-wrap:break-word}.kXUfPb.Vp9uZ{line-height:20px}.RtoYlb{padding:18px}.hfgVwf{margin-top:12px}.IxZjcf .hfgVwf{margin-bottom:12px}.OdF8Fd{float:right;padding-left:16px}.p1vimb{border-radius:8px;display:block}.rkvY3c{clear:both}.CgE3Ac{margin:0 16px}.I9mEQ{padding-bottom:12px}.LnMnt{border-collapse:collapse;border-spacing:0;width:100%}.LnMnt td{padding-top:0;padding-bottom:0;padding-right:8px}.LnMnt .s5aIid{padding-right:0}.IxZjcf{border-bottom:1px solid #dfe1e5}.sjsZvd{vertical-align:top}.OE1use{text-align:left}.BSv1qf{text-align:center}.HlHBvc{text-align:right}.uEec3{font-size:12px;line-height:16px}.uEec3.HrGdeb{color:rgba(255,255,255,.7)}.uEec3.AP7Wnd{color:#70757A}.IfyLsd{float:left;margin-right:8px}.rl7ilb{display:block;clear:both}.mSx1Ee{padding-left:48px;margin:0}.v9i61e{padding-bottom:8px}.ko6Hn{text-decoration:underline}.ZTv9Bb{display:block}.nVTMpe{border-radius:8px}.X7NTVe{display:table;width:100%;padding-right:16px;box-sizing:border-box}.tHmfQe{display:table-cell;padding:12px 0 12px 16px}.UHtrk{width:72px}.HBTM6d{width:30px}.XS7yGd{display:table-cell;text-align:center;vertical-align:middle;padding:12px 0 12px 8px}.am3QBf{display:table;vertical-align:top}.Icx6Cd{margin:0 auto 8px}.mAdjQc{text-align:right}.rLshyf,.BmP5tf{padding-top:12px;padding-bottom:12px}.w1C3Le,.BmP5tf,.G5NbBd{padding-left:16px;padding-right:16px;}.G5NbBd{padding-bottom:12px}.nMymef{display:flex}.G5eFlf{flex:1;display:block}.nMymef span{text-align:center}</style><div><!--SW_C_X--></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><span><div class="BNeawe deIvCb AP7Wnd">Bill Gates</div></span><span><div class="BNeawe tAd8D AP7Wnd">American business magnate � <span class="BNeawe"><a href="/url?q=https://www.gatesnotes.com/&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQMHoECBUQBA&amp;usg=AOvVaw2OfUwfVVqG5axi5WdIqJBq"><span class="tAd8D AP7Wnd"><span class="r0bn4c rQMQod">gatesnotes.com</span></span></a></span></div></span></div><div><div><div><div class="Xdlr0d"><div class="idg8be"><a class="BVG0Nb" href="/imgres?imgurl=http://www.gstatic.com/tv/thumb/persons/614/614_v9_bc.jpg&amp;imgrefurl=http://google.com/search?tbm%3Disch%26q%3DBill%2BGates&amp;h=1440&amp;w=1080&amp;tbnid=Er687YiGz0HolM:&amp;q=bill+gates&amp;tbnh=186&amp;tbnw=139&amp;usg=AI4_-kQgtMwKmhZPubq2GDVn8tirbMDj2g&amp;vet=1&amp;docid=B0IgcVmd7SaSiM&amp;itg=1&amp;hl=en&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ9QF6BAgVEAU"><div><img class="WddBJd" style="max-width:none;height:128px;max-height:128px" alt="www.gstatic.com/tv/thumb/persons/614/614_v9_bc.jpg" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQb44JdRVHe4HaY0vgYS8LnzQ15Px5MU5dvQMQhaTafbJsbkRhWk3U3tA&amp;s=0"></div></a><a class="BVG0Nb" href="/imgres?imgurl=https://ichef.bbci.co.uk/news/1024/branded_news/13605/production/_111256397_060306797-1.jpg&amp;imgrefurl=https://www.bbc.com/news/business-51883377&amp;h=576&amp;w=1024&amp;tbnid=JZeznmxfBVD-BM:&amp;q=bill+gates&amp;tbnh=93&amp;tbnw=165&amp;usg=AI4_-kQrycuipeaLmYXiNz0kjspdpSNFtw&amp;vet=1&amp;docid=jIJSiJuBiWHN6M&amp;hl=en&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ9QF6BAgVEAc"><div><img class="WddBJd" style="max-width:none;height:128px;max-height:128px" alt="ichef.bbci.co.uk/news/1024/branded_news/13605/prod..." src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQj046aiEigLbVSO6vcguOIgVaxyD6OFYv9WZYFcfq-5ANmlabLgoe3bPU&amp;s=0"></div></a><a class="BVG0Nb" href="/imgres?imgurl=https://image.cnbcfm.com/api/v1/image/105189375-_Y2A2493c.jpg?v%3D1525701183%26w%3D1400%26h%3D950&amp;imgrefurl=https://www.cnbc.com/2020/01/27/bill-gates-in-2018-world-needs-to-prepare-for-pandemics-just-like-war.html&amp;h=950&amp;w=1400&amp;tbnid=XMsxAm5GkAqShM:&amp;q=bill+gates&amp;tbnh=93&amp;tbnw=137&amp;usg=AI4_-kRyR62rH8hUiXZifsshzLLzASJ0gQ&amp;vet=1&amp;docid=LzJJVd6yTPv1LM&amp;hl=en&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ9QF6BAgVEAk"><div><img class="WddBJd" style="max-width:none;height:128px;max-height:128px" alt="image.cnbcfm.com/api/v1/image/105189375-_Y2A2493c...." src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRLVpTHfrEZe5_nUM9SbdZ0xnjYLDkyR4d3TkGonWZmvdAbAWECgsxcHNk&amp;s=0"></div></a><a class="BVG0Nb" href="/imgres?imgurl=https://cdn.britannica.com/47/188747-050-1D34E743/Bill-Gates-2011.jpg&amp;imgrefurl=https://www.britannica.com/biography/Bill-Gates&amp;h=1600&amp;w=1182&amp;tbnid=GQEjjuCgfiilBM:&amp;q=bill+gates&amp;tbnh=93&amp;tbnw=69&amp;usg=AI4_-kSeWjBIwEgXhvlpjHZLlvcTgWwyew&amp;vet=1&amp;docid=RFHUbgblZATz3M&amp;hl=en&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ9QF6BAgVEAs"><div><img class="WddBJd" style="max-width:none;height:128px;max-height:128px" alt="cdn.britannica.com/47/188747-050-1D34E743/Bill-Gat..." src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcS1T40AAqwrEuvZf2384omW2uLo7OC-0vvPrSkPIbhX9a-UxcF7xT5Qzw&amp;s=0"></div></a><div class="mHhylf"><div class="WZ5GJf"><a class="qN9Ked" href="https://www.google.com/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;ei=AWGfXpnLNoWIlwSCz4zYCA&amp;q=bill+gates&amp;tbm=isch&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ7Al6BAgVEA0"><button class="DXk5Me Qi9Fd"><img class="hWHuJ" alt="Arrow" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYAgMAAACdGdVrAAAADFBMVEVMaXFChfRChfRChfT0tCPZAAAAA3RSTlMAgFJEkGxNAAAAL0lEQVR4AWPADxgdwBT3BTDF9AUiuhdC6WNK/v///y+UggrClSA07EWVglmEFwAA5eYSExeCwigAAAAASUVORK5CYII=" style="max-width:24px;max-height:24px"></button><div class="BNeawe ji5jpf tAd8D AP7Wnd">View all</div></a></div></div></div></div></div></div></div><div class="Q0HXG"></div><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div class="BNeawe s3v9rd AP7Wnd">William Henry Gates III is an American business magnate, software developer, investor, and philanthropist. He is best known as the co-founder of Microsoft Corporation. <span class="BNeawe"><a href="/url?q=https://en.wikipedia.org/wiki/Bill_Gates&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQmhMwCXoECBUQDw&amp;usg=AOvVaw13JZQHJl8IAFdKLg3TiZva"><span class="XLloXe AP7Wnd">Wikipedia</span></a></span></div></div></div></div></div><div class="vbShOe kCrYT"><div class="AVsepf"><div class="BNeawe s3v9rd AP7Wnd"><span><span class="BNeawe s3v9rd AP7Wnd">Born</span></span>: <span><span class="BNeawe tAd8D AP7Wnd">October 28, 1955 (age 64�years), <span class="BNeawe"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Seattle&amp;stick=H4sIAAAAAAAAAOPgE-LQz9U3MDTPK1ECs1Iss4q0xLKTrfQLUvMLclKBVFFxfp5VUn5R3iJW9uDUxJKSnFQA3EAC8jgAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQmxMwC3oECBUQEQ"><span class="XLloXe AP7Wnd">Seattle, Washington, United States</span></a></span></span></span></div></div><div class="AVsepf"><div class="BNeawe s3v9rd AP7Wnd"><span><span class="BNeawe s3v9rd AP7Wnd">Net worth</span></span>: <span><span class="BNeawe tAd8D AP7Wnd">104.9�billion USD (2020)</span></span></div></div><div class="AVsepf"><div class="BNeawe s3v9rd AP7Wnd"><span><span class="BNeawe s3v9rd AP7Wnd">Spouse</span></span>: <span><span class="BNeawe tAd8D AP7Wnd"><span class="BNeawe"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Melinda+Gates&amp;stick=H4sIAAAAAAAAAOPgE-LQz9U3MDTPK1ECs1JyC0y0JLKTrfQLUvMLclKBVFFxfp5VcUF-aXHqIlZe39SczLyURAX3xJLUYgAPK94WQAAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQmxMwDXoECBUQFA"><span class="XLloXe AP7Wnd">Melinda Gates</span></a></span> (m. 1994)</span></span></div></div><div class="AVsepf u2x1Od"><div class="BNeawe s3v9rd AP7Wnd"><span><span class="BNeawe s3v9rd AP7Wnd">Children</span></span>: <span><span class="BNeawe tAd8D AP7Wnd"><span class="BNeawe"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Phoebe+Adele+Gates&amp;stick=H4sIAAAAAAAAAOPgE-LQz9U3MDTPK1HiArGM8uLTK9K1pLKTrfQLUvMLclKBVFFxfp5VckZmTkpRat4iVqGAjPzUpFQFx5TUnFQF98SS1GIApBC390kAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQmxMwDnoECBUQFg"><span class="XLloXe AP7Wnd">Phoebe Adele Gates</span></a></span>, <span class="BNeawe"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Jennifer+Katharine+Gates&amp;stick=H4sIAAAAAAAAAOPgE-LQz9U3MDTPK1HiArGMik2rzCy1pLKTrfQLUvMLclKBVFFxfp5VckZmTkpRat4iVgmv1Ly8zLTUIgXvxJKMxKLMvFQF98SS1GIA_to9-U8AAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQmxMwDnoECBUQFw"><span class="XLloXe AP7Wnd">Jennifer Katharine Gates</span></a></span> and <span class="BNeawe"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Rory+John+Gates&amp;stick=H4sIAAAAAAAAAOPgE-LQz9U3MDTPK1HiArGM8uLTK8y1pLKTrfQLUvMLclKBVFFxfp5VckZmTkpRat4iVv6g_KJKBa_8jDwF98SS1GIAeol3sUYAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQmxMwDnoECBUQGA"><span class="XLloXe AP7Wnd">Rory John Gates</span></a></span></span></span></div></div></div><div class="Q0HXG"></div><div><div class="kCrYT"><span class="punez"><div class="BNeawe wyrwXc AP7Wnd">Books</div></span></div><div><div><div class="Xdlr0d"><div class="idg8be"><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=The+Road+Ahead&amp;stick=H4sIAAAAAAAAAONgFuLQz9U3MDTPK1HiBLOKC9PLtaSyk630k_Lzs_UTS0sy8ousQOxihfy8nMpFrHwhGakKQfmJKQqOGamJKQDFVavbRAAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMA96BAgVEBs"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:168px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQURmW5Q2gYV2Xqgj6sNzvSDSlRult-Nsz12LqHspXJJNj83IRxrT1mw7oHZl32NWY4F6NVJ4o&amp;s=0" style="max-width:112px;max-height:168px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">The Road Ahead</div></div><div><div class="BNeawe tAd8D AP7Wnd">1995</div></div></div></div></div></a><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=How+to+Avoid+a+Climate+Disaster:+The+Solutions+We+Have+and+the+Breakthroughs+We+Need&amp;stick=H4sIAAAAAAAAAB3JvQrCMBAA4EGELi6OToejS8xU6GZ16ORiwbGczdGEpDlILhVfxyf1Z_vgq1bbSs3qqOso-42alNa2zn4Y9XDY-bFRD2avsIjl1PycgWN4vdd9x08QhtPCzgDCObgZheDiMmah1EBvCW4cijiOGe4EHS4EGA3Id9pE6MUmLpP975XIfADfgwCBjgAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMA96BAgVEB0"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:168px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTW6qOOrOUSQs6cim0oeuESXqZbo-sAdWYW_N8EMO4EuiJyr30SIiW-w_UvLFXmlvdh9Bo4UZA&amp;s=0" style="max-width:112px;max-height:168px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">How to Avoid a Climate Disaster: The Solutions We Have and the Breakthroughs We Need</div></div><div><div class="BNeawe tAd8D AP7Wnd">2020</div></div></div></div></div></a><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Business+@+the+Speed+of+Thought&amp;stick=H4sIAAAAAAAAAONgFuLQz9U3MDTPK1HiBLMq0rJztaSyk630k_Lzs_UTS0sy8ousQOxihfy8nMpFrPJOpcWZeanFxQoOCiUZqQrBBampKQr5aQohGfml6RklAGNfku1VAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMA96BAgVEB8"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:168px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKvS_BLQ7tGe5erHl3aJrlqEn8RrZ8WC9aq0PWCAwFwKDH8o1hml-8ccmXPzN3eslcduiRlx0&amp;s=0" style="max-width:112px;max-height:168px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">Business @ the Speed of Thought: Using a Digital Nervous System</div></div><div><div class="BNeawe tAd8D AP7Wnd">1999</div></div></div></div></div></a><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Level+6+Pack+Bill+Gates&amp;stick=H4sIAAAAAAAAAONgFuLQz9U3MDTPK1Hi1U_XNzRMMi9MSykrStOSyk620k_Kz8_WTywtycgvsgKxixXy83IqF7GK-6SWpeYomCkEJCZnKzhl5uQouCeWpBYDALQapdtRAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMA96BAgVECE"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:168px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRiScYljVxbOUVYeYI2mAq3jf5HCwNiSyDlCP2iFCVAAgOpalwwheU3UvIKOXFMdk0efT4u96w&amp;s=0" style="max-width:112px;max-height:168px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">Level 6 Pack</div></div></div></div></div></a><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Unleashing+the+Power+of+Creativity:+A+%22This+I+Believe%22+Essay+Bill+Gates&amp;stick=H4sIAAAAAAAAABXGsQrCMBAA0EGELi6OTkdGlzOT2M2KFDcHnSWWMwlNc5A7K_kdv1R802sW6wYn3Nl9VrNCj9Z6f0hlegzbzTi0-GQe0b01cGn_F-Cc6nfZ33MiJyFmDxoIrvyhAvyCUyGncY5aWziCuYUocIGOUqSZDJxFXIUupgS9U5Ifi2Iti4EAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMA96BAgVECM"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:168px"><img class="EYOsld" alt="" src="https://www.gstatic.com/knowledgecard/book-110.png" style="max-width:112px;max-height:168px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">Unleashing the Power of Creativity: A "This I Believe" Essay</div></div><div><div class="BNeawe tAd8D AP7Wnd">2006</div></div></div></div></div></a><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Plpr3:+Road+Ahead,+the+CD+for+Pack+RLA+Bill+Gates&amp;stick=H4sIAAAAAAAAAONgFuLQz9U3MDTPK1Hi1U_XNzRMq8oqM0pLNtaSyk620k_Kz8_WTywtycgvsgKxixXy83IqF7EaBuQUFBlbKQTlJ6YoOGakJqboKJRkpCo4uyik5RcpBCQmZysE-TgqOGXm5Ci4J5akFgMA2kFow2sAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMA96BAgVECU"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:168px"><img class="EYOsld" alt="" src="https://www.gstatic.com/knowledgecard/book-110.png" style="max-width:112px;max-height:168px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">Plpr3: Road Ahead, the CD for Pack RLA</div></div><div><div class="BNeawe tAd8D AP7Wnd">2008</div></div></div></div></div></a></div></div></div></div></div><div><div class="kCrYT"><span class="punez"><div class="BNeawe wyrwXc AP7Wnd">People also search for</div></span></div><div><div><div class="Xdlr0d"><div class="idg8be"><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Elon+Musk&amp;stick=H4sIAAAAAAAAAONgFuLQz9U3MDTPK1HiBLGM86rSDLWkspOt9AtS8wtyUoFUUXF-nlVxZkpqeWJl8SJWTtec_DwF39LibACr73rEPwAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMBB6BAgVECg"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:112px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQLVi3aaVSfDSEr5rYmNtRYX1Yn2gcFAddZ-FGEYtvm9NPOAQLRsdA9HeufvtAA-LD8PXV8tQ&amp;s=0" style="max-width:112px;max-height:112px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">Elon Musk</div></div><div><div class="BNeawe tAd8D AP7Wnd">Trending</div></div></div></div></div></a><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Jeff+Bezos&amp;stick=H4sIAAAAAAAAAONgFuLQz9U3MDTPK1HiBLMMq8wstaSyk630C1LzC3JSgVRRcX6eVXFmSmp5YmXxIlYur9S0NAWn1Kr8YgDRHi-MQAAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMBB6BAgVECo"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:112px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSz7Jrv_gOzw_8qC52GMP89GP59qP7ThP5ZDWV8Jw4sqHU8_ObvfIcK-qnORlD_5DfBUfSNpQ&amp;s=0" style="max-width:112px;max-height:112px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">Jeff Bezos</div></div></div></div></div></a><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Steve+Jobs&amp;stick=H4sIAAAAAAAAAONgFuLQz9U3MDTPK1ECs8wqjYu0pLKTrfQLUvMLclKBVFFxfp5VcWZKanliZfEiVq7gktSyVAWv_KRiAJbeZIo_AAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMBB6BAgVECw"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:112px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ6r8znzdM0t37pruY_Tzw5hVAFvIJLt-Edkq3AG-lZWrmcGJ59TJRTnMuwlKnt1d03nwpuLg&amp;s=0" style="max-width:112px;max-height:112px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">Steve Jobs</div></div></div></div></div></a><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Melinda+Gates&amp;stick=H4sIAAAAAAAAAONgFuLQz9U3MDTPK1ECs1JyC0y0pLKTrfQLUvMLclKBVFFxfp5VcWZKanliZfEiVl7f1JzMvJREBffEktRiAIkdDTpCAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMBB6BAgVEC4"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:112px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQRsi_pzVkrGJ-i-5ev7NIvva8bW2OwA1JxK-Db_HN4f_FHEZ_9EC2ZGhFjLjwdFoAUtUa3qw&amp;s=0" style="max-width:112px;max-height:112px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">Melinda Gates</div></div><div><div class="BNeawe tAd8D AP7Wnd">Spouse</div></div></div></div></div></a><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Mark+Zuckerberg&amp;stick=H4sIAAAAAAAAAONgFuLQz9U3MDTPK1HiBLEszFLyKrWkspOt9AtS8wtyUoFUUXF-nlVxZkpqeWJl8SJWft_EomyFqNLk7NSipNSidACCqbUkRQAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMBB6BAgVEDA"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:112px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTIWNNdgzPWmq6z-a6ExmasXBb3dTdSsQHXZKFqKWo4_jdGF3IouQeQZeyb3YV5UoJ4lSU54w&amp;s=0" style="max-width:112px;max-height:112px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">Mark Zuckerberg</div></div></div></div></div></a><a class="BVG0Nb" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=Warren+Buffett&amp;stick=H4sIAAAAAAAAAONgFuLQz9U3MDTPK1HiBLNS4iuLtaSyk630C1LzC3JSgVRRcX6eVXFmSmp5YmXxIla-8MSiotQ8BafStLTUkhIAghq3DkQAAAA&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0I4BMBB6BAgVEDI"><div><div style="width:112px"><div class="S7Jdze" style="width:112px;height:112px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR5e8wUjC9obp9GktMZNFnq5nP2TNWULUlL8lE7qoX4WLCSu9wyJbNdV5jTHMf7oHGClkRa2Q&amp;s=0" style="max-width:112px;max-height:112px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd">Warren Buffett</div></div></div></div></div></a></div></div></div></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><div class="BNeawe deIvCb AP7Wnd"><span class="FCUp0c rQMQod">Top stories</span></div></div><div><div><div><div class="Xdlr0d"><div class="idg8be"><a class="BVG0Nb" href="/url?q=https://www.bellingencourier.com.au/story/6730717/pm-bill-gates-share-windows-into-virus/%3Fcs%3D9397&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0PADMBF6BAgCEAI&amp;usg=AOvVaw3RDLLmeIkH3tScDfzpDzgN"><div><div style="width:232px"><div class="S7Jdze" style="width:232px;height:128px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQIvSKzWy8OxcCndZekuVNsQ2lhuMkGlE1eRgAHjxDaPXqXONVa2PNRDvZ8S53K8PtuhyoopRzS&amp;s" style="max-width:232px;max-height:128px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><span class="rQMQod Xb5VRe">PM, Bill Gates share windows into virus</span></div></div><div><div class="BNeawe tAd8D AP7Wnd">The Bellingen Shire Courier Sun
  13 hours ago</div></div></div></div></div></a><a class="BVG0Nb" href="/url?q=https://www.9news.com.au/national/coronavirus-live-updates-australia-virgin-voluntary-administration-scott-morrison-bill-gates-who-us-assistance-uk-deaths-cases/554f81ce-fce7-4700-bcab-c872d0e14f23&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0PADMBJ6BAgCEAY&amp;usg=AOvVaw3DZT2stx65SFLcOjInNnah"><div><div style="width:232px"><div class="S7Jdze" style="width:232px;height:128px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRExNbpoH7cOfOkag8mjcEl8lvJjmPxsKh7dXLqCMDnLHpbw1yXMJBAfCpSw8hkTS-Aq5dQaxBH&amp;s" style="max-width:232px;max-height:128px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><span class="rQMQod Xb5VRe">Coronavirus live updates: Virgin Australia CEO vows no redunancies in 
  voluntary administration; PM speaks with Bill ...</span></div></div><div><div class="BNeawe tAd8D AP7Wnd">9News
  23 mins ago</div></div></div></div></div></a><a class="BVG0Nb" href="/url?q=https://www.marketwatch.com/story/bill-gates-has-a-big-problem-with-trumps-dangerous-decision-to-defund-the-world-health-organization-2020-04-15&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0PADMBN6BAgCEAo&amp;usg=AOvVaw2GSvuRyU66Si1XNxrFyZ27"><div><div style="width:232px"><div class="S7Jdze" style="background-color:;width:232px;height:128px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSQkBpHe2Z8Rm5AdIgUeFvm2en-aXHGErzA5D-4p9wbISzhd_e_lCiz2qyllOUe_BztV3mrioKL&amp;s" style="max-width:232px;max-height:128px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><span class="rQMQod Xb5VRe">Bill Gates has a big problem with Trump&#8217;s &#8216;dangerous&#8217; decision to defund 
  the World Health Organization</span></div></div><div><div class="BNeawe tAd8D AP7Wnd">MarketWatch
  3 days ago</div></div></div></div></div></a><a class="BVG0Nb" href="/url?q=https://www.dailymail.co.uk/news/article-8221473/Bill-Gates-says-Donald-Trump-dangerous-cutting-500million-funding-WHO.html&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0PADMBR6BAgCEA4&amp;usg=AOvVaw1YDP126v7vZbtbJiPefUJC"><div><div style="width:232px"><div class="S7Jdze" style="background-color:;width:232px;height:128px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTAB-0QUVucnt2nR4Bcdl7K2LcMS6KAA5Z0iz8skjrYmtWj1hDbXSZ18pkBREEngHGisgSo7l8Z&amp;s" style="max-width:232px;max-height:128px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><span class="rQMQod Xb5VRe">Bill Gates says Donald Trump is 'dangerous' for cutting $500million in 
  funding to the WHO</span></div></div><div><div class="BNeawe tAd8D AP7Wnd">Daily Mail
  6 days ago</div></div></div></div></div></a><a class="BVG0Nb" href="/url?q=https://www.inc.com/justin-bariso/bill-gates-says-coronavirus-will-change-life-forever-heres-how-to-adapt.html&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0PADMBV6BAgCEBI&amp;usg=AOvVaw0Y-lsGTO3tpSc_NpVEPOpD"><div><div style="width:232px"><div class="S7Jdze" style="width:232px;height:128px"><img class="EYOsld" alt="" src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRvmk3nFLMuoH_rU4FYbn1UIphxFZtWe-mUi4FhHRP5Y24lHz8J0iVZyPdv9Ga01CS_PJt_w3PR&amp;s" style="max-width:232px;max-height:128px"></div><div class="RWuggc kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><span class="rQMQod Xb5VRe">Bill Gates Says the Coronavirus Will Change Life Forever. Here's How to 
  Adapt</span></div></div><div><div class="BNeawe tAd8D AP7Wnd">Inc.com
  1 week ago</div></div></div></div></div></a></div></div></div></div></div></div></div><div class="ZINbbc xpd O9g5cc uUPGi"><h2 class="wITvVb"><span><div class="BNeawe deIvCb AP7Wnd"><span class="FCUp0c rQMQod">People also ask</span></div></span></h2><div class="LKSyXe"></div><div class="BxVv8d"><span><div class="BNeawe s3v9rd AP7Wnd">How did Bill Gates get rich?</div></span></div><div class="M56Nqc"><div class="Z8j5ae"><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div class="BNeawe s3v9rd AP7Wnd"><span class="FCUp0c rQMQod">Bill Gates became</span> so <span class="FCUp0c rQMQod">rich</span> because of 3 things. The genius behind him was that <span class="FCUp0c rQMQod">Bill Gates</span> bought an existing operating system and modified it and sold it to IBM. ... So every time a PC manufacturer makes a computer, they would need to pay Microsoft a small fee to have Windows as the OS.</div></div></div></div></div><div class="x54gtf"></div><div class="kCrYT"><a href="/url?q=https://www.quora.com/How-is-Bill-Gates-still-the-worlds-richest-man&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFnoECAUQAg&amp;usg=AOvVaw2MtyU6p0opjfdd306x-Bb1"><span><div class="BNeawe vvjwJb AP7Wnd">How is Bill Gates still the world's richest man? - Quora</div></span><span><div class="BNeawe UPmit AP7Wnd">https://www.quora.com &gt; How-is-Bill-Gates-still-the-worlds-richest-man</div></span></a></div></div></div></div><div><div class="PDHNXc"><div class="iU269d TeHtNe"><span class="kXUfPb Vp9uZ"><a class="RtoYlb" href="https://www.google.com/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;ei=AWGfXpnLNoWIlwSCz4zYCA&amp;q=How+did+Bill+Gates+get+rich?&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQzmd6BAgNEAM">More results</a></span></div></div></div></div><div class="LKSyXe"></div><div class="BxVv8d"><span><div class="BNeawe s3v9rd AP7Wnd">Did Bill Gates die?</div></span></div><div class="M56Nqc"><div class="Z8j5ae"><div><div class="ZINbbc xpd O9g5cc uUPGi"><div><div class="kCrYT"><a href="/url?q=https://en.wikipedia.org/wiki/Bill_Gates&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFnoECAYQAQ&amp;usg=AOvVaw2PZYDS4gvFgvhCHh6xHOti"><span></span></a></div><div class="CgE3Ac I9mEQ"><table class="LnMnt"><thead><tr><td class="IxZjcf sjsZvd OE1use"><div class="hfgVwf"><div class="BNeawe uEec3 AP7Wnd">Bill Gates</div></div></td><td class="IxZjcf sjsZvd s5aIid OE1use"><div class="hfgVwf"></div></td></tr></thead><tbody><tr><td class="sjsZvd OE1use"><div class="hfgVwf"><div class="BNeawe s3v9rd AP7Wnd">Gates in 2018</div></div></td><td class="sjsZvd s5aIid OE1use"><div class="hfgVwf"></div></td></tr><tr><td class="sjsZvd OE1use"><div class="hfgVwf"><div class="BNeawe s3v9rd AP7Wnd">Born</div></div></td><td class="sjsZvd s5aIid OE1use"><div class="hfgVwf"><div class="BNeawe s3v9rd AP7Wnd">William Henry Gates III October 28, 1955 Seattle, Washington, U.S.</div></div></td></tr><tr><td class="sjsZvd OE1use"><div class="hfgVwf"><div class="BNeawe s3v9rd AP7Wnd">Occupation</div></div></td><td class="sjsZvd s5aIid OE1use"><div class="hfgVwf"><div class="BNeawe s3v9rd AP7Wnd">Software developer investor entrepreneur philanthropist</div></div></td></tr><tr><td class="sjsZvd OE1use"><div class="hfgVwf"><div class="BNeawe s3v9rd AP7Wnd">Years active</div></div></td><td class="sjsZvd s5aIid OE1use"><div class="hfgVwf"><div class="BNeawe s3v9rd AP7Wnd">1975&#8211;present</div></div></td></tr></tbody></table></div><div class="hwc"><div class="Q0HXG"></div><div class="kCrYT"><a href="/url?q=https://en.wikipedia.org/wiki/Bill_Gates&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFnoECAYQAg&amp;usg=AOvVaw2EcdeBssQjMAC4IXsWwoT2"><div><span><div class="BNeawe vvjwJb AP7Wnd">Bill Gates - Wikipedia</div></span><span><div class="BNeawe UPmit AP7Wnd">https://en.wikipedia.org &gt; wiki &gt; Bill_Gates</div></span></div></a></div></div></div></div></div></div><div><div class="PDHNXc"><div class="iU269d TeHtNe"><span class="kXUfPb Vp9uZ"><a class="RtoYlb" href="https://www.google.com/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;ei=AWGfXpnLNoWIlwSCz4zYCA&amp;q=Did+Bill+Gates+die?&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQzmd6BAgNEAY">More results</a></span></div></div></div></div><div class="LKSyXe"></div><div class="BxVv8d"><span><div class="BNeawe s3v9rd AP7Wnd">Why did Bill Gates leave Microsoft?</div></span></div><div class="M56Nqc"><div class="Z8j5ae"><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div class="BNeawe s3v9rd AP7Wnd"><span class="FCUp0c rQMQod">Bill Gates</span> has stepped down from the board of <span class="FCUp0c rQMQod">Microsoft</span> to spend more time on his philanthropic endeavors, the company announced Friday afternoon. Though he will remain technology advisor to CEO Satya Nadella, this move reduces his involvement with the company to the lowest level it has ever been.</div></div></div></div></div><div class="x54gtf"></div><div class="kCrYT"><a href="/url?q=https://techcrunch.com/2020/03/13/bill-gates-leaves-microsofts-board/&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFnoECAkQAg&amp;usg=AOvVaw1AJbHVHAqwA1TNZVs5jqOA"><span><div class="BNeawe vvjwJb AP7Wnd">Bill Gates leaves Microsoft's board | TechCrunch</div></span><span><div class="BNeawe UPmit AP7Wnd">https://techcrunch.com &gt; 2020/03/13 &gt; bill-gates-leaves-microsofts-board</div></span></a></div></div></div></div><div><div class="PDHNXc"><div class="iU269d TeHtNe"><span class="kXUfPb Vp9uZ"><a class="RtoYlb" href="https://www.google.com/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;ei=AWGfXpnLNoWIlwSCz4zYCA&amp;q=Why+did+Bill+Gates+leave+Microsoft?&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQzmd6BAgNEAk">More results</a></span></div></div></div></div><div class="LKSyXe"></div><div class="BxVv8d"><span><div class="BNeawe s3v9rd AP7Wnd">Is Bill Gates the richest man in the world?</div></span></div><div class="M56Nqc"><div class="Z8j5ae"><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div class="BNeawe s3v9rd AP7Wnd"><span class="FCUp0c rQMQod">Bill Gates</span> was named the <span class="FCUp0c rQMQod">richest man in the world</span> by Forbes' annual list of the <span class="FCUp0c rQMQod">world's</span> billionaires. This was the 16th time that the founder of Microsoft claimed the top spot. Carlos Slim came in second for the second consecutive time.</div></div></div></div></div><div class="x54gtf"></div><div class="kCrYT"><a href="/url?q=https://en.wikipedia.org/wiki/The_World%2527s_Billionaires&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFnoECAwQAg&amp;usg=AOvVaw2ZcNlSzjnkouq3nWvQnEtk"><span><div class="BNeawe vvjwJb AP7Wnd">The World's Billionaires - Wikipedia</div></span><span><div class="BNeawe UPmit AP7Wnd">https://en.wikipedia.org &gt; wiki &gt; The_World's_Billionaires</div></span></a></div></div></div></div><div><div class="PDHNXc"><div class="iU269d TeHtNe"><span class="kXUfPb Vp9uZ"><a class="RtoYlb" href="https://www.google.com/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;ei=AWGfXpnLNoWIlwSCz4zYCA&amp;q=Is+Bill+Gates+the+richest+man+in+the+world?&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQzmd6BAgNEAw">More results</a></span></div></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><a href="/url?q=https://www.gatesnotes.com/&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFjAeegQIEBAB&amp;usg=AOvVaw1IPOqxi1N1G1psVkeBAI7D"><div class="BNeawe vvjwJb AP7Wnd">Home | Bill Gates</div><div class="BNeawe UPmit AP7Wnd">https://www.gatesnotes.com</div></a></div><div class="x54gtf"></div><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div><div class="BNeawe s3v9rd AP7Wnd">&#8220;Although eating whole-grain bread might make me feel virtuous, in my experience it just never seems to taste as good as white bread.&#8221; read post. Become a�...</div></div></div></div></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><a href="/url?q=https://en.wikipedia.org/wiki/Bill_Gates&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFjAfegQIAxAB&amp;usg=AOvVaw3W-Cb33zo2EP25BWr6gko5"><div class="BNeawe vvjwJb AP7Wnd">Bill Gates - Wikipedia</div><div class="BNeawe UPmit AP7Wnd">https://en.wikipedia.org &#8250; wiki &#8250; Bill_Gates</div></a></div><div class="x54gtf"></div><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div><div class="BNeawe s3v9rd AP7Wnd">William Henry Gates III (born October 28, 1955) is an American business magnate, software developer, investor, and philanthropist. He is best known as the co-founder of Microsoft Corporation.
  <span class="BNeawe"><a href="/url?q=https://en.wikipedia.org/wiki/Bill_Gates_Sr.&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0gIwH3oECAMQAg&amp;usg=AOvVaw0KzW9xy_pnkp_nCZRB8WDW"><span class="XLloXe AP7Wnd">Bill Gates Sr.</span></a></span> � <span class="BNeawe"><a href="/url?q=https://en.wikipedia.org/wiki/Bill_Gates%2527s_house&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0gIwH3oECAMQAw&amp;usg=AOvVaw11DgOKBFmhkdXeDolwCBSk"><span class="XLloXe AP7Wnd">Bill Gates's house</span></a></span> � <span class="BNeawe"><a href="/url?q=https://en.wikipedia.org/wiki/Bill_Gates_(disambiguation)&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0gIwH3oECAMQBA&amp;usg=AOvVaw0Wy3EokwLIA8mbPQpj8Jpq"><span class="XLloXe AP7Wnd">Bill Gates (disambiguation)</span></a></span> � <span class="BNeawe"><a href="/url?q=https://en.wikipedia.org/wiki/Melinda_Gates&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ0gIwH3oECAMQBQ&amp;usg=AOvVaw2vLbXli42yNk8IVSwDa0x0"><span class="XLloXe AP7Wnd">Melinda Gates</span></a></span>
  
  Years active: <span class="r0bn4c rQMQod">1975&#8211;present</span>
  Parents: <span class="BNeawe"><a href="/url?q=https://en.wikipedia.org/wiki/Bill_Gates_Sr.&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQs2YwH3oECAMQCQ&amp;usg=AOvVaw1-XsIo7SKg_8ECLhGdW2ik"><span class="XLloXe AP7Wnd">Bill Gates Sr.</span></a></span><span class="r0bn4c rQMQod"> (father); </span><span class="BNeawe"><a href="/url?q=https://en.wikipedia.org/wiki/Mary_Maxwell_Gates&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQs2YwH3oECAMQCg&amp;usg=AOvVaw3EQbjEDVgNOa2w3tCPImTb"><span class="XLloXe AP7Wnd">Mary Maxwell Gates</span></a></span><span class="r0bn4c rQMQod"> (mother)</span>
  Occupation: <span class="r0bn4c rQMQod">Software developer; investor; entrepreneur; philanthropist</span>
  Known for: <span class="r0bn4c rQMQod">Co-founder of </span><span class="BNeawe"><a href="/url?q=https://en.wikipedia.org/wiki/Microsoft&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQs2YwH3oECAMQDQ&amp;usg=AOvVaw2jtHAdp1-Mc0iIQBXrd7mG"><span class="XLloXe AP7Wnd">Microsoft</span></a></span></div></div></div></div></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><a href="/url?q=https://twitter.com/BillGates%3Fref_src%3Dtwsrc%255Egoogle%257Ctwcamp%255Eserp%257Ctwgr%255Eauthor&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ6F56BAgUEAE&amp;usg=AOvVaw3HcFdPQQ0BIYPorHUya9XY"><div class="BNeawe vvjwJb AP7Wnd">Bill Gates &#10003;</div><div class="BNeawe UPmit AP7Wnd">Twitter &#8250; BillGates</div></a></div><div class="x54gtf"></div><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div class="Ap5OSd"><div class="BNeawe s3v9rd AP7Wnd">Halting funding for the World Health Organization during a world health crisis is as dangerous as it sounds. Their work is slowing the spread of COVID-19 and if that work is stopped no other organization can replace them. The world needs @WHO now more than ever.</div></div><div><div class="BNeawe s3v9rd AP7Wnd"><span class="r0bn4c rQMQod">7 days ago</span><span class="r0bn4c rQMQod"> � </span><span class="BNeawe"><a href="/url?q=https://twitter.com/BillGates/status/1250292126643941376%3Fref_src%3Dtwsrc%255Egoogle%257Ctwcamp%255Eserp%257Ctwgr%255Etweet&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQglQwIXoECBQQAw&amp;usg=AOvVaw1VEvsgDaUKzP6MAK4TNylS"><span class="XLloXe AP7Wnd">View on Twitter</span></a></span></div></div></div></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><a href="/url?q=https://www.facebook.com/BillGates/&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFjAiegQICxAB&amp;usg=AOvVaw2MiV_ez82B59qXIe3z7I6K"><div class="BNeawe vvjwJb AP7Wnd">Bill Gates - Home | Facebook</div><div class="BNeawe UPmit AP7Wnd">https://www.facebook.com &#8250; Pages &#8250; Public Figure</div></a></div><div class="x54gtf"></div><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div><div class="BNeawe s3v9rd AP7Wnd">Bill Gates. 21M likes. Co-chair, Bill and Melinda Gates Foundation.</div></div></div></div></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><a href="/url?q=https://www.youtube.com/channel/UCnEiGCE13SUI7ZvojTAVBKw&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFjAjegQIERAB&amp;usg=AOvVaw1e3rJbjR0cdJwG-CmMWa8q"><div class="BNeawe vvjwJb AP7Wnd">Bill Gates - YouTube</div><div class="BNeawe UPmit AP7Wnd">https://www.youtube.com &#8250; channel</div></a></div><div class="x54gtf"></div><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div><div class="BNeawe s3v9rd AP7Wnd">Hi, I'm Bill Gates. Tune in here to watch videos about my work. On this channel, I post videos about the issues I'm focused on: saving lives, improving educa...</div></div></div></div></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><a href="/url?q=https://www.forbes.com/profile/bill-gates/&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFjAkegQIChAB&amp;usg=AOvVaw36I33tyEZNFEHV13HRT_Re"><div class="BNeawe vvjwJb AP7Wnd">Bill Gates - Forbes</div><div class="BNeawe UPmit AP7Wnd">https://www.forbes.com &#8250; profile &#8250; bill-gates</div></a></div><div class="x54gtf"></div><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div><div class="BNeawe s3v9rd AP7Wnd">With his wife Melinda, Bill Gates chairs the Bill &amp; Melinda Gates Foundation, the world's largest private charitable foundation. In February 2020, the Gates�...</div></div></div></div></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><a href="/url?q=https://www.businessinsider.com/coronavirus-conspiracy-bill-gates-infowars-2020-4&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFjAlegQIBBAB&amp;usg=AOvVaw1KEHYAaAhJZeD_VkXkDg1_"><div class="BNeawe vvjwJb AP7Wnd">The bizarre conspiracy theory that Bill Gates caused COVID-19 ...</div><div class="BNeawe UPmit AP7Wnd">https://www.businessinsider.com &#8250; coronavirus-conspiracy-bill-gates-infow...</div></a></div><div class="x54gtf"></div><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div><div class="BNeawe s3v9rd AP7Wnd"><span class="r0bn4c rQMQod">2 days ago</span><span class="r0bn4c rQMQod"> � </span>From fringe conspiracy theorists to mainstream conservative pundits, this is how Bill Gates became the scapegoat for the coronavirus�...</div></div></div></div></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><a href="/url?q=https://www.nytimes.com/2020/04/17/technology/bill-gates-virus-conspiracy-theories.html&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFjAmegQICBAB&amp;usg=AOvVaw1UIu2ZVn8xtQDqhL1FVaeE"><div class="BNeawe vvjwJb AP7Wnd">Bill Gates, at Odds With Trump on Virus, Becomes a Right-Wing Target</div><div class="BNeawe UPmit AP7Wnd">https://www.nytimes.com &#8250; technology &#8250; bill-gates-virus-conspiracy-theories</div></a></div><div class="x54gtf"></div><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div><div class="BNeawe s3v9rd AP7Wnd"><span class="r0bn4c rQMQod">5 days ago</span><span class="r0bn4c rQMQod"> � </span>In a 2015 speech, Bill Gates warned that the greatest risk to humanity was not nuclear war but an infectious virus that could threaten the lives of�...</div></div></div></div></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><a href="/url?q=https://www.gatesfoundation.org/&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQFjAnegQIBxAB&amp;usg=AOvVaw0tXkGa_ss47rGe_EGA3Vwz"><div class="BNeawe vvjwJb AP7Wnd">Bill &amp; Melinda Gates Foundation</div><div class="BNeawe UPmit AP7Wnd">https://www.gatesfoundation.org</div></a></div><div class="x54gtf"></div><div class="kCrYT"><div><div class="BNeawe s3v9rd AP7Wnd"><div><div><div class="BNeawe s3v9rd AP7Wnd">We seek to unlock the possibility inside every individual. We see equal value in all lives. And so we are dedicated to improving the quality of life for individuals�...</div></div></div></div></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div><div class="CgE3Ac I9mEQ"><table class="LnMnt"><tbody><tr><td class="sjsZvd s5aIid OE1use"><div class="hfgVwf"><div class="BNeawe s3v9rd AP7Wnd"><span class="r0bn4c rQMQod">Some results may have been removed under data protection law in Europe. </span><span class="BNeawe"><a href="/url?q=https://www.google.com/policies/faq&amp;sa=U&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ2Dx6BAgAEAI&amp;usg=AOvVaw3OThylqtifh6lgrboVTrjo"><span class="tAd8D AP7Wnd"><span class="ko6Hn r0bn4c rQMQod">Learn more</span></span></a></span></div></div></td></tr></tbody></table></div><div class="hwc"></div></div></div></div><div><div class="ZINbbc xpd O9g5cc uUPGi"><div class="kCrYT"><div class="q4vBJc"></div><span><div class="BNeawe deIvCb AP7Wnd"><span class="FCUp0c rQMQod">Related searches</span></div></span></div><div class="Q0HXG"></div><div class="X7NTVe"><a class="tHmfQe" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates'+wife&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ1QJ6BAgBEAE"><div class="am3QBf"><div><span><div class="BNeawe deIvCb AP7Wnd">bill gates' wife</div></span></div></div></a><div class="HBTM6d XS7yGd"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates'+wife"><div class="BNeawe mAdjQc uEec3 AP7Wnd">&gt;</div></a></div></div><div class="Q0HXG"></div><div class="X7NTVe"><a class="tHmfQe" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+biography&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ1QJ6BAgBEAI"><div class="am3QBf"><div><span><div class="BNeawe deIvCb AP7Wnd">bill gates biography</div></span></div></div></a><div class="HBTM6d XS7yGd"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+biography"><div class="BNeawe mAdjQc uEec3 AP7Wnd">&gt;</div></a></div></div><div class="Q0HXG"></div><div class="X7NTVe"><a class="tHmfQe" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+books&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ1QJ6BAgBEAM"><div class="am3QBf"><div><span><div class="BNeawe deIvCb AP7Wnd">bill gates books</div></span></div></div></a><div class="HBTM6d XS7yGd"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+books"><div class="BNeawe mAdjQc uEec3 AP7Wnd">&gt;</div></a></div></div><div class="Q0HXG"></div><div class="X7NTVe"><a class="tHmfQe" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+children&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ1QJ6BAgBEAQ"><div class="am3QBf"><div><span><div class="BNeawe deIvCb AP7Wnd">bill gates children</div></span></div></div></a><div class="HBTM6d XS7yGd"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+children"><div class="BNeawe mAdjQc uEec3 AP7Wnd">&gt;</div></a></div></div><div class="Q0HXG"></div><div class="X7NTVe"><a class="tHmfQe" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+education&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ1QJ6BAgBEAU"><div class="am3QBf"><div><span><div class="BNeawe deIvCb AP7Wnd">bill gates education</div></span></div></div></a><div class="HBTM6d XS7yGd"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+education"><div class="BNeawe mAdjQc uEec3 AP7Wnd">&gt;</div></a></div></div><div class="Q0HXG"></div><div class="X7NTVe"><a class="tHmfQe" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+facts&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ1QJ6BAgBEAY"><div class="am3QBf"><div><span><div class="BNeawe deIvCb AP7Wnd">bill gates facts</div></span></div></div></a><div class="HBTM6d XS7yGd"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+facts"><div class="BNeawe mAdjQc uEec3 AP7Wnd">&gt;</div></a></div></div><div class="Q0HXG"></div><div class="X7NTVe"><a class="tHmfQe" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+family&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ1QJ6BAgBEAc"><div class="am3QBf"><div><span><div class="BNeawe deIvCb AP7Wnd">bill gates family</div></span></div></div></a><div class="HBTM6d XS7yGd"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+family"><div class="BNeawe mAdjQc uEec3 AP7Wnd">&gt;</div></a></div></div><div class="Q0HXG"></div><div class="X7NTVe"><a class="tHmfQe" href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+height&amp;sa=X&amp;ved=2ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ1QJ6BAgBEAg"><div class="am3QBf"><div><span><div class="BNeawe deIvCb AP7Wnd">bill gates height</div></span></div></div></a><div class="HBTM6d XS7yGd"><a href="/search?lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;q=bill+gates+height"><div class="BNeawe mAdjQc uEec3 AP7Wnd">&gt;</div></a></div></div></div></div><footer> <div>  <div class="ZINbbc xpd O9g5cc uUPGi BmP5tf"><div class="nMymef MUxGbd lyLwlc"><a class="nBDE1b G5eFlf" href="/search?q=bill+gates&amp;lr=lang_en&amp;gbv=1&amp;hl=en&amp;ie=UTF-8&amp;tbs=lr:lang_1en&amp;ei=AWGfXpnLNoWIlwSCz4zYCA&amp;start=10&amp;sa=N" aria-label="Next page">Next &gt;</a></div></div> </div>  <div id="mCljob"><div><a href="/url?q=https://accounts.google.com/ServiceLogin%3Fcontinue%3Dhttps://www.google.com/search%253Fq%253Dbill%252Bgates%2526gws_rd%253Dcr%2526gbv%253D1%2526lr%253Dlang_en%2526hl%253Den%2526ei%253Dx%26hl%3Den&amp;sa=U&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQxs8CCK4B&amp;usg=AOvVaw2pmK8KZOfnQzvZi9An84wS">Sign in</a></div><div><a class="ksTU4c" href="https://www.google.com/preferences?hl=en-NL&amp;fg=1&amp;sa=X&amp;ved=0ahUKEwjZz9zvtvroAhUFxIUKHYInA4sQ5fUCCK8B">Settings</a><a class="ksTU4c" href="//policies.google.com/privacy?fg=1">Privacy</a><a class="ksTU4c" href="//policies.google.com/terms?fg=1">Terms</a></div></div> </footer><script nonce="sy4xAKW0KNvcEZLmwf6uxQ==">(function(){
  function b(a){for(a=a.target||a.srcElement;a&&"A"!=a.nodeName;)a=a.parentElement;a&&(a.href||"").match(/\/search.*[?&]tbm=isch/)&&(a.href+="&biw="+document.documentElement.clientWidth,a.href+="&bih="+document.documentElement.clientHeight)}document.addEventListener("click",b,!1);document.addEventListener("touchStart",b,!1);}).call(this);</script></div><!-- cctlcm 5 cctlcm --><textarea class="csi" name="csi" style="display:none"></textarea><script nonce="sy4xAKW0KNvcEZLmwf6uxQ==">(function(){var e='AWGfXpnLNoWIlwSCz4zYCA';var sn='web';(function(){
  function x(a){if(!a||"none"==a.style.display)return 0;if(document.defaultView&&document.defaultView.getComputedStyle){var b=document.defaultView.getComputedStyle(a);if(b&&("hidden"==b.visibility||"0px"==b.height&&"0px"==b.width))return 0}if(!a.getBoundingClientRect)return 1;var c=a.getBoundingClientRect();a=c.left+window.pageXOffset;b=c.top+window.pageYOffset;var f=c.width;c=c.height;var h=0;if(0>=c&&0>=f)return h;0>b+c?h=2:b>=(window.innerHeight||document.documentElement.clientHeight)&&(h=4);if(0>
  a+f||a>=(window.innerWidth||document.documentElement.clientWidth))h|=8;return h||1};var y=e,z=sn,H=[];function I(a,b,c){a="/gen_204?atyp=csi&s="+(z||"web")+"&t="+a+("&lite=1&ei="+y+"&conn="+(window.navigator&&window.navigator.connection?window.navigator.connection.type:-1)+b);b="&rt=";for(var f in c)a+=b+f+"."+c[f],b=",";return a}function J(a){a={prt:a};window.wsrt&&(a.wsrt=window.wsrt);return a}function K(a){window.ping?window.ping(a):(new Image).src=a}
  (function(){for(var a=(new Date).getTime()-window.start,b=J(a),c=0,f=0,h=0,A=document.getElementsByTagName("img"),n="&imn="+A.length+"&biw="+window.innerWidth+"&bih="+window.innerHeight,L=function(g,p){g.onload=function(){f=(new Date).getTime()-window.start;p&&++t==h&&(c=f,B());g.onload=null}},B=function(){n+="&ima="+h;b.aft=c;K(I("aft",n,b))},t=0,M=0,d=void 0;d=A[M++];){var q=x(d),r=1==q;r&&++h;var m=d.hasAttribute("data-ilite"),u=d.hasAttribute("data-deferred")||m,C=d.getAttribute("data-src")||
  d.getAttribute("data-lzysrc");H.push([q,u,!u&&C,google.ldi&&d.id&&google.ldi[d.id]||m&&C]);m=(q=d.complete&&!u)&&Number(d.getAttribute("data-iml"))||0;q&&m?(r&&++t,m&&(d=m-window.start,r&&(c=Math.max(c,d)),f=Math.max(f,d))):L(d,r)}c||(c=a);f||(f=c);t==h&&B();google.rglh&&google.rglh();window.addEventListener("load",function(){window.setTimeout(function(){b.ol=(new Date).getTime()-window.start;b.iml=f;var g=window.performance&&window.performance.timing;g&&(b.rqst=g.responseEnd-g.requestStart,b.rspt=
  g.responseEnd-g.responseStart);for(var p=g=0,D=0,E=0,F=0,N=0,k;k=H[N++];){var l=k[0],v=k[1],O=k[2];k=k[3];var P=0==l,w=l&8,G=l&4;l=1==l||2==l||w&&!G;!l||w||v&&!k||++D;v&&(l&&k&&++g,G&&!k&&++p);P||w?O||++F:v||++E}n+="&ime="+D+("&imex="+E+"&imeh="+F)+("&imea="+g+"&imeb="+p);K(I("all",n,b))},0)},!1)})();}).call(this);})();</script><script nonce="sy4xAKW0KNvcEZLmwf6uxQ==">(function(){(function(){google.csct={};google.csct.ps='AOvVaw3Oqq5xYUZPGTh8BKXcx1bT\x26ust\x3d1587589761931319';})();})();(function(){(function(){google.csct.rd=true;})();})();google.drty&&google.drty();</script></body></html>

Any help would be much appreciated :)

Xpath with | character does not return element with duplicated text

Using a modified version of the html sample in query_test.go:

const htmlQuerySample = `<!DOCTYPE html><html lang="en-US">
<head>
<title>Hello,World!</title>
</head>
<body>
<div class="container">
<header>
	<!-- Logo -->
   <h1>City Gallery</h1>
</header>  
<nav>
  <ul>
    <li><a href="/London">London</a></li>
    <li><a href="/Paris">Paris</a></li>
    <li><a href="/Tokyo">Tokyo</a></li>
    <li><a href="/Tokyo2">Tokyo</a></li>
  </ul>
</nav>
<article>
  <h1>London</h1>
  <img src="pic_mountain.jpg" alt="Mountain View" style="width:304px;height:228px;">
  <p>London is the capital city of England. It is the most populous city in the  United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
  <p>Standing on the River Thames, London has been a major settlement for two millennia, its history going back to its founding by the Romans, who named it Londinium.</p>
</article>
<footer>Copyright &copy; W3Schools.com</footer>
</div>
</body>
</html>
`

(added extra Tokyo li element)

Using xpath "//nav/ul/li/a/text()|//div/ul/li/a/text()" (the second condition after the | is just an example and not meant to find anything additional), I would expect four elements to be returned - London, Paris, Tokyo, Tokyo. Instead, it returns three, dropping the second Tokyo element. Removing the | character and second condition returns four elements. Similarly, if I remove the text() part, then it also returns four elements.

Small unit test illustrating the issue:

func TestXpathQuery(t *testing.T) {
	reader := strings.NewReader(htmlQuerySample)
	doc, err := htmlquery.Parse(reader)

	if err != nil {
		t.Errorf("Error loading document: %s", err.Error())
		return
	}

	doTestXpath(t, doc, "//nav/ul/li/a/text()")
	doTestXpath(t, doc, "//nav/ul/li/a|//div/ul/li/a")
	doTestXpath(t, doc, "//nav/ul/li/a/text()|//div/ul/li/a/text()")
}

func doTestXpath(t *testing.T, doc *html.Node, xpath string) {
	found, err := htmlquery.QueryAll(doc, xpath)

	if err != nil {
		t.Error(err.Error())
	}

	if len(found) != 4 {
		t.Errorf("Xpath: %s - expected 4 elements found %d", xpath, len(found))
	}
}

Gives the following results:

--- FAIL: TestXpathQuery (0.00s)
    ...\xpath_test.go:978: Xpath: //nav/ul/li/a/text()|//div/ul/li/a/text() - expected 4 elements found 3
FAIL

release ?

Can we have a release (or pre-release, say) with a version so people can keep track of the changes after a particular point they integrated in their app.

Thanks in advance.

Using Libraries to Convert HTML to XPath

Hey, this is not an issue but I have been unable to understand why there are not many reputable packages that advertise the ability to turn CSS/HTML to XPaths. Can I use this library to convert CSS to an XPath?

Does it support "string" xpath function?

I want to use
htmlquery.Query(parse, "string(//div[@id='postlist'])")
to extract the text content, but it return nil. It seem it does not support the "string" xpath function?

A bug when I use htmlquery.InnerText

htmlquery.InnerText(htmlquery.FindOne(n, "//td[2]"))

In this code, if htmlquery.FindOne(n, "//td[2]") is nil, so htmlquery.InnerText will throw out an error, which is not convincing. Better to return a nil too.

Neat Project!! 🚀

👍 I enjoy using your htmlquery module.

Wonder if there is any way to handle a click event without having to making thing complicated (e.eg using a full-pledged webdriver)

Any plans on supporting object-oriented style nodes?

As of today, one must write, e.g.,

// let `root` be a *html.Node
htmlquery.SelectAttr(htmlquery.FindOne(root, `.//someelement[@id="some=id"]`), "some-attribute")

in order to retrieve the attribute some-attribute from an element. However, it would be more natural (IMO) and shorter to write, e.g.,

root.FindOne(`.//someelement[@id="some-id"]`).SelectAttr("some-attribute")

I wouldn't mind trying and submitting a PR, as I'm just a Go rookie.


Btw, thanks for the great library! 🙂

`replace()` on a query doesn't seem to work

package main

import (
	"fmt"
	"strings"

	"github.com/antchfx/htmlquery"
)

func main() {
	s := `<html><a href="https://github.com/cashapp/hermit-build/releases/download/go-tools/stringer-v0.1.12-darwin-amd64.bz2">foo</a></html>`
	doc, err := htmlquery.Parse(strings.NewReader(s))
	if err != nil {
		panic(err)
	}
	nodes, err := htmlquery.QueryAll(doc, `replace((//a[contains(@href, '/stringer-')])/@href, '^.*/stringer-v([^-]*)-.*$', '$1')`)
	if err != nil {
		panic(err)
	}
	for _, node := range nodes {
		fmt.Println(htmlquery.OutputHTML(node, false))
	}
}

On playground: https://go.dev/play/p/jxU6UgH0DnK
The same content+query works fine on https://www.freeformatter.com/xpath-tester.html

The above example without replace() works fine: https://go.dev/play/p/N22KULbkgRu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.