Skip to content

Add Social_Bookmark_extraction.R for parsing social bookmark HTML exports - #3

Open
charles-hebert wants to merge 1 commit into
mainfrom
codex/create-r-script-for-social-bookmark-extraction
Open

Add Social_Bookmark_extraction.R for parsing social bookmark HTML exports#3
charles-hebert wants to merge 1 commit into
mainfrom
codex/create-r-script-for-social-bookmark-extraction

Conversation

@charles-hebert

Copy link
Copy Markdown
Owner

Motivation

  • Provide an R utility to extract post URLs and nearby title/snippet text from local HTML exports from social platforms without relying on fragile CSS classes.
  • Normalize and clean extracted links (resolve relative URLs, strip tracking/query parameters) and ensure robust handling of missing/empty titles.

Description

  • Add Social_Bookmark_extraction.R which uses rvest, dplyr, and stringr and defines an editable html_path input variable.
  • Collects all <a> tags and filters likely social post links using a configurable post_pattern with filter(str_detect(...)) (examples include status, feed/update, posts, story.php, permalink).
  • Resolves relative links via url_absolute() using a file:// base, and removes URL query/tracking parameters with str_remove("\\?.*$").
  • Extracts the nearest parent div/span (or nearest ancestor with visible text) as the title/snippet via XPath; assigns "No Title Found" for empty or missing titles; returns a clean tibble and writes bookmarks_cleaned.csv.

Testing

  • Attempted to parse the script with Rscript -e "parse(file='Social_Bookmark_extraction.R')", but this failed because Rscript is not available in the current environment.
  • No further automated R runtime tests were executed in this environment due to the missing Rscript executable.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1f6954ccb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# Convert relative URLs to absolute
url = url_absolute(url_raw, base = base_url),
# Remove tracking/query params (everything after '?')
url = str_remove(url, "\\?.*$")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep post-identifying query strings when normalizing URLs

Stripping everything after ? removes required identifiers for query-based post URLs (for example Facebook story.php?story_fbid=...&id=...), so different posts collapse to the same normalized URL and are then dropped by distinct(url, .keep_all = TRUE). This silently loses data whenever exports contain such links; the normalization should remove only known tracking parameters rather than the entire query string.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant