0

I would be interested in collecting statistics on what are the most upvoted questions on SO. Using Geb, I tried to extract the relevant HTML:

@Integration
class PlayTestsSpec extends GebSpec {
    void "check stackoverflow"() {
        when: "Go to so"
            go "https://stackoverflow.com/questions/1223354/undo-git-pull-how-to-bring-repos-to-old-state"
        $('#sidebar.show-votes div.related.js-gps-related-questions').children()
        then:
            System.out.println("Done.")
    }
}

I actually end up with an array (?) of divs:

[<div class="spacer">, <div class="spacer">, <div class="spacer">, <div class="spacer">, <div class="spacer">, <div class="spacer">, <div class="spacer">, <div class="spacer">, <div class="spacer">, <div class="spacer">]

How would I iterate over each of these divs and extract the vote counter and question title?

TMOTTM
  • 3,286
  • 6
  • 32
  • 63

1 Answers1

0

Create a RelatedQuestionModule and then use children().moduleList(RelatedQuestionModule).

Better, use the Stack Overflow Data Explorer, which is meant for this sort of thing.

chrylis -cautiouslyoptimistic-
  • 75,269
  • 21
  • 115
  • 152