LIHKGr icon indicating copy to clipboard operation
LIHKGr copied to clipboard

Updated CSS selector for upvote & downvote

Open elgarteo opened this issue 3 years ago • 0 comments

Due to changes in the layout of LIHKG, this package is no longer able to fetch the upvote and downvote counts. The following code with the updated CSS selector works with the new interface:

  ##get_upvote
  upvote <- html %>% html_nodes("._36ZEkSvpdj_igmog0nluzh") %>%
    html_node("._3imUf8qB9LmLpk_t5PjDm4 > div:nth-child(1) > label") %>% 
    html_text()
  ##get_downvote
  downvote <- html %>% html_nodes("._36ZEkSvpdj_igmog0nluzh") %>%
    html_node("._3imUf8qB9LmLpk_t5PjDm4 > div:nth-child(2) > label") %>% 
    html_text()

Interestingly, it is possible to fetch the supposedly hidden upvote and downvote counts of newly published posts, since the numbers are present in the HTML and only hidden by CSS.

elgarteo avatar Apr 16 '21 05:04 elgarteo