Questions tagged [goquery]

A little like that j-thing, only in Go.

A little like that j-thing, only in Go. https://github.com/PuerkitoBio/goquery

76 questions
1
vote
1 answer

How to retrieve the height of the selected HTML element using Golang?

I was using goquery to parse HTML and I need to retrieve the height of these HTML elements but goquery doesn't have a jquery like .css() method? How can I achieve something like this?
1
vote
1 answer

How to retrieve full HTML of a child element with goquery?

Why does the following test fail? func TestGetFirstElementHtml(t *testing.T) { test := `

My paragraph

` doc, _ := goquery.NewDocumentFromReader(strings.NewReader(test)) var childrenHtml []string …
Alexander van Trijffel
  • 2,916
  • 1
  • 29
  • 31
1
vote
1 answer

Doctype with goquery

Is there any possibility to retrieve document doctype with goquery? I've tried several things, but any worked. I suppose that it is possible, because NodeName func has switch with "html.DoctypeNode" case. That code didn't find…
nexequ
  • 321
  • 5
  • 16
1
vote
1 answer

How to output results to CSV of a concurrent web scraper in Go?

I'm new to Go and am trying to take advantage of the concurrency in Go to build a basic scraper to pull extract title, meta description, and meta keywords from URLs. I am able to print out the results to terminal with the concurrency but can't…
credizian
  • 469
  • 5
  • 20
1
vote
1 answer

Cannot Select Direct Child from *goquery.Selection

In jQuery and CSS, you can use the > character which points to only the direct child element. This works in Goquery with something like doc.Find("body > ul"), but when you already have a *goquery.Selection and you want to select a direct child…
Ari Seyhun
  • 11,506
  • 16
  • 62
  • 109
1
vote
1 answer

How to break out of switch case from inside a function defined inside the switch case in golang?

The question sounds weird but I didn't know any better way to put it. I am using goquery and I am inside a switch-case: switch{ case url == url1: doc.Find("xyz").Each(func(i int,s *goquery.Selection){ a,_ := s.Attr("href") …
Krash
  • 2,085
  • 3
  • 13
  • 36
1
vote
1 answer

goquery: stop parsing when another element is reached

Suppose I have this HTML page. I want to parse it using Go and goquery:

Heading 1

Stuff1
Brent
  • 805
  • 9
  • 20
1
vote
1 answer

GoQuery selection extractor not working

I am attempting to extract the target attribute and add to a slice from the HTML snippet
1
vote
2 answers

Goquery Select meta[property=og:image]?

Goquery Syntax-wise, it is as close as possible to jQuery, with the same function names when possible, and that warm and fuzzy chainable interface. doc.Find("meta[property='og:image']").Each(func(i int, s *goquery.Selection) { fmt.Fprintln("og…
Chris
  • 18,075
  • 15
  • 59
  • 77
1
vote
1 answer

Search tags by id with goQuery

I would like to retrieve all the tags with a specific id using Go. Apparently the easiest way to do that is go is to use goquery. Assume I am looking for ul tags with id MyTag in a website site. I would like to list all the li contained in such a…
meto
  • 3,425
  • 10
  • 37
  • 49
1
vote
3 answers

Getting blank return when using GoQuery to get video src

I'm trying to get the .mp4 video source of a vine, using GoQuery. However when I run it, I get nothing, no error, or return. Just a blank line. package main import ( "fmt" "log" "github.com/PuerkitoBio/goquery" ) func getMP4URL() { doc,…
ChiChu
  • 63
  • 1
  • 4
0
votes
2 answers

goquery get all

tags from just one selector

I have the following example

1

2

3

How can I extract the 3 p tags using goquery or CSS…
David Meléndez
  • 389
  • 5
  • 15
0
votes
0 answers

Process a

with goquery

I'm trying to get the following element from a page with goquery

ALIASES: alias,1 “alias2," “alias3,”
DOB: December 22, 1986
NATIONALITY: Brazil
CITIZENSHIP:…

David Meléndez
  • 389
  • 5
  • 15
0
votes
0 answers

How to get text from

without taking the span

I have the following function, func getMosWantedInfo(doc *goquery.Document) { doc.Find("div.flex-align-center.bg-base-lightest.padding-1.margin-1").Each(func(i int, s *goquery.Selection) { // For each item found, get the title …
David Meléndez
  • 389
  • 5
  • 15

0
votes
0 answers

How to use css selector in Golang

In Ruby, I have something like contents = html_doc.css("img + a"). How would I do this in Go? I am trying to use Goquery but I am unsure of how to convert it. Specifically, I tried doc.find("img") but it doesn't find anything for some reason Edit:…
Logan X.
  • 11
  • 3