Git Product home page Git Product logo

Comments (2)

zhengchun avatar zhengchun commented on June 15, 2024

hi,@lexfrei , your xpath expression look correct, it will find and output follow element <a href="/apk/niantic-inc/pokemon-go/pokemon-go-0-55-0-release/">Pokémon GO 0.55.0</a>, if you want to get a link,you need a href attr value.

elem := htmlquery.FindOne(root, `//*[@id="whatsnew"]/div/div[2]/strong/a/@href`)
for _, attr := range elem.Attr {
	if attr.Key == "href" {
		urlToAPK := attr.Val
		fmt.Println(urlToAPK)
	}
}

update1:
the xpath always returns a element object, not a text, even you specified a@href in your xpath expression,
so,htmlquery.InnerText method returns a find element inner text, not @href attr value of this element.

update2:
I added a SelectAttr method 9853284

elem := htmlquery.FindOne(root, `//*[@id="whatsnew"]/div/div[2]/strong/a/@href`)
fmt.Println(htmlquery.SelectAttr(elem,"href"))

from xquery.

lexfrei avatar lexfrei commented on June 15, 2024

Thx for response!
This isn't totally clear for me, but i got it.
Feel free to resolve! <3

from xquery.

Related Issues (20)

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.