{"id":15691959,"url":"https://github.com/talaatmagdyx/socials_regex","last_synced_at":"2025-05-07T23:47:44.052Z","repository":{"id":178016083,"uuid":"649018359","full_name":"talaatmagdyx/socials_regex","owner":"talaatmagdyx","description":"🪡 Social account detection and extraction in ruby, e.g. for crawling/scraping.","archived":false,"fork":false,"pushed_at":"2023-12-24T16:55:01.000Z","size":47,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-20T04:34:16.797Z","etag":null,"topics":["ruby","web-crawling","web-scraping"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/socials_regex","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/talaatmagdyx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-03T14:14:42.000Z","updated_at":"2023-09-13T06:59:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"fee19c12-0d74-4cee-b9bd-33124ae9e8a7","html_url":"https://github.com/talaatmagdyx/socials_regex","commit_stats":null,"previous_names":["talaatmagdyx/socials_regex"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talaatmagdyx%2Fsocials_regex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talaatmagdyx%2Fsocials_regex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talaatmagdyx%2Fsocials_regex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/talaatmagdyx%2Fsocials_regex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/talaatmagdyx","download_url":"https://codeload.github.com/talaatmagdyx/socials_regex/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252973622,"owners_count":21834105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ruby","web-crawling","web-scraping"],"created_at":"2024-10-03T18:26:46.814Z","updated_at":"2025-05-07T23:47:44.023Z","avatar_url":"https://github.com/talaatmagdyx.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SocialsRegex\n\n----\nSocial Regex Account Detection and Extraction for Ruby. Detect and extract URLs of social accounts: throw in URLs, get back URLs of social media profiles by type.\n\nFeatures:\n\n- detect the platform a url points to (all major platforms supported)\n- extract the information contained within the url (without opening the url, of course)\n- extract emails and phone numbers from hyperlinks\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n    $ bundle add socials_regex\n\nIf bundler is not being used to manage dependencies, install the gem by executing:\n\n    $ gem install socials_regex\n\n### Requirements\nThis gem requires Ruby 2.6+\n\n## Usage\n\n```ruby\nrequire 'socials_regex'\n\nsupported_platforms = SocialsRegex::Platforms.all\n# [:PLATFORM_FACEBOOK, :PLATFORM_GITHUB, :PLATFORM_LINKEDIN, :PLATFORM_TWITTER, :PLATFORM_INSTAGRAM, :PLATFORM_YOUTUBE, \n# :PLATFORM_EMAIL, :PLATFORM_HACKER_NEWS, :PLATFORM_MEDIUM, :PLATFORM_PHONE, :PLATFORM_REDDIT,\n# :PLATFORM_SKYPE, :PLATFORM_SNAPCHAT, :PLATFORM_STACKEXCHANGE, :PLATFORM_STACKOVERFLOW, :PLATFORM_STACKOVERFLOW, \n# :PLATFORM_TELEGRAM, :PLATFORM_VIMEO, :PLATFORM_XING, :PLATFORM_ANGELLIST, :PLATFORM_CRUNCHBASE, \n# :PLATFORM_STACKEXCHANGE_NETWORK, :PLATFORM_WHATSAPP, :PLATFORM_YELP]\n\n\nsupported_regexes = SocialsRegex::Regexes.all\n# [:ANGELLIST_URL_REGEX, :CRUNCHBASE_URL_REGEX, :EMAIL_URL_REGEX, :FACEBOOK_URL_REGEX, :GITHUB_URL_REGEX, :HACKERNEWS_URL_REGEX,\n# :INSTAGRAM_URL_REGEX, :LINKEDIN_URL_REGEX, :MEDIUM_URL_REGEX, :PHONE_URL_REGEX, :REDDIT_URL_REGEX, :SKYPE_URL_REGEX, :SNAPCHAT_URL_REGEX,\n# :STACKEXCHANGE_URL_REGEX, :STACKEXCHANGE_NETWORK_URL_REGEX, :STACKOVERFLOW_URL_REGEX, :TELEGRAM_URL_REGEX, :TWITTER_URL_REGEX,\n# :VIMEO_URL_REGEX, :XING_URL_REGEX, :YOUTUBE_URL_REGEX, :WHATSAPP_URL_REGEX, :YELP_URL_REGEX] \n\n# get all regex for all regex\nplatform_regexes = SocialsRegex::Socials::PLATFORMS_REGEX\n# example [:yelp, {:company=\u003e/(?:https?:\\/\\/)?(?:www\\.)?yelp\\.com\\/biz\\/(?\u003ccompany\u003e[A-Za-z0-9_-]+)/}] \n\n# get regex for specific platforms \ntwitter_regex = SocialsRegex::Socials::PLATFORMS_REGEX[:twitter]\n# {:status=\u003e/(?:https?:)?\\/\\/(?:[A-Za-z]+\\.)?twitter\\.com\\/@?(?\u003cusername\u003e[A-Za-z0-9_]+)\\/status\\/(?\u003ctweet_id\u003e[0-9]+)\\/?/,\n# :user=\u003e/(?:https?:)?\\/\\/(?:[A-Za-z]+\\.)?twitter\\.com\\/@?(?!home|share|privacy|tos)(?\u003cusername\u003e[A-Za-z0-9_]+)\\/?/}\n\n\n# how to extract social data from links or texts\ntext = 'https://twitter.com/karllorey/status/1259924082067374088' \\\n             'https://twitter.com/karllorey12/status/12599240820673740883' \\\n             'http://crunchbase.com/organization/acme-corp jeff@amazon.com mailto:plususer+test@gmail.com' \\\n             'https://facebook.com/peter.parker https://www.facebook.com/profile.php?id=100004123456789' \\\n             'https://github.com/talaatmagdyx https://github.com/talaatmagdyx/socials_regex' \\\n             'https://news.ycombinator.com/item?id=23290375 https://instagram.com/__disco__dude' \\\n             'https://www.linkedin.com/in/talaatmagdyx/ https://medium.com/does-exist/some-post-123abc'\nextract = SocialsRegex::Extraction.new(text: text)\n# #\u003cSocialsRegex::Extraction:0x00007f5c51d0c488 @text= \"https://twitter.com/karllorey/status/......\"\u003e\n\n# to extract all links and data \nextract.extract_matches_per_platform\n# {:crunchbase=\u003e{:company=\u003e[{:matched=\u003e\"http://crunchbase.com/organization/acme-corp\", \"organization\"=\u003e\"acme-corp\"}]},\n# :medium=\u003e{:post=\u003e[{:matched=\u003e\"https://medium.com/does-exist/some-post-123abc\", \"username\"=\u003enil, \"publication\"=\u003e\"does-exist\", \"slug\"=\u003e\"some-post\", \"post_id\"=\u003e\"123abc\"}]},\n#   :hackernews=\u003e{:item=\u003e[{:matched=\u003e\"https://news.ycombinator.com/item?id=23290375\", \"item\"=\u003e\"23290375\"}]},\n#  :email=\u003e{:email=\u003e[{:matched=\u003e\"jeff@amazon.com\", \"email\"=\u003e\"jeff@amazon.com\"}, {:matched=\u003e\"mailto:plususer+test@gmail.comhttps\", \"email\"=\u003e\"plususer+test@gmail.comhttps\"}]},\n#    :instagram=\u003e{:profile=\u003e[{:matched=\u003e\"https://instagram.com/__disco__dudehttps\", \"username\"=\u003e\"__disco__dudehttps\"}]},\n\n\n# to extract links or data using specific platform like instagram\nextract.extract_matches_by_platform(platform: 'instagram') # or use :instagram\n# {\"instagram\"=\u003e{:profile=\u003e[{:matched=\u003e\"https://instagram.com/__disco__dudehttps\", \"username\"=\u003e\"__disco__dudehttps\"}]}}\n\n# to extract links or data using specific regex like twitter status\nmatches = extract.extract_matches_by_regex(regex: SocialsRegex::Regexes::TWITTER_URL_REGEX[:status])\n# [{:matched=\u003e\"https://twitter.com/karllorey/status/1259924082067374088\", \"username\"=\u003e\"karllorey\", \"tweet_id\"=\u003e\"1259924082067374088\"},\n# {:matched=\u003e\"https://twitter.com/karllorey12/status/12599240820673740883\", \"username\"=\u003e\"karllorey12\", \"tweet_id\"=\u003e\"12599240820673740883\"}]\n\n\n```\n\n# References\n- [social-media-profiles-regexs](https://github.com/lorey/social-media-profiles-regexs):\n  extract urls of social media profiles with regular expressions\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at [Contributing](https://github.com/talaatmagdyx/socials_regex/blob/master/.github/CONTRIBUTING.md). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/talaatmagdyx/socials_regex/blob/master/.github/CODE_OF_CONDUCT.md).\n\n## [ChangeLog](./CHANGELOG.md)\n\n## Reporting Bugs / Feature Requests\n\nPlease [open an Issue on GitHub](https://github.com/talaatmagdyx/socials_regex/issues) if you have feedback, new feature requests, or want to report a bug. Thank you!\n\n## Pull Request\nPlease read [Contributing](https://github.com/talaatmagdyx/socials_regex/blob/master/.github/PULL_REQUEST_TEMPLATE.md)\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the SocialsRegex project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/talaatmagdyx/socials_regex/blob/master/.github/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalaatmagdyx%2Fsocials_regex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftalaatmagdyx%2Fsocials_regex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftalaatmagdyx%2Fsocials_regex/lists"}