ivan-rivera/RedditExtractor

Add ability to extract flair from comments and threads?

Opened this issue · 1 comments

Hello! This is a wonderful package for getting really interesting data. I was wondering if it would be possible to add flairs to the scraped comments. I was going to do this myself by editing the below function, I was having trouble getting a toy json and request_url from the other functions to properly test it. Would it be as simple as?

build_comments_content_df <- function(json, request_url) data.frame(
  url = strip_json(request_url),
  author = extract_comments_attributes(json, "author"),
  date = extract_comments_attributes(json, "created_utc") |> timestamp_to_date(),
  timestamp = extract_comments_attributes(json, "created_utc"),
  score = extract_comments_attributes(json, "score"),
  upvotes = extract_comments_attributes(json, "ups"),
  downvotes = extract_comments_attributes(json, "downs"),
  golds = extract_comments_attributes(json, "gilded"),
  comment = extract_comments_attributes(json, "body"),
  flair = extract_comments_attributes(json, "author_flair_text"), ## Changed line
  comment_id = build_comment_ids(json),
  stringsAsFactors = FALSE
)

I'm sorry if it is more complicated than that, but I'd be willing to help work on it.

Also this has previously been discussed here and I was interested in trouble shooting the issue the original user ran into:
https://www.reddit.com/r/redditdev/comments/10q2s59/using_redditextractor_to_scrape_flairs/

Hi @tnieuwe

If you want to do this as a one-off exercise, then you can simply clone the codebase and try this on your own end. If you'd like to update the codebase, then I suggest you open up a PR and try to implement this change