{"id":21649966,"url":"https://github.com/jwc20/fcisapi","last_synced_at":"2025-03-20T03:20:19.984Z","repository":{"id":37253032,"uuid":"503562472","full_name":"jwc20/fcisapi","owner":"jwc20","description":"A scraper API for fetching workplace fatality and catastrophe reports from the United States Department of Labor website.","archived":false,"fork":false,"pushed_at":"2024-08-26T13:40:29.000Z","size":100,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T04:35:37.849Z","etag":null,"topics":["accidents-analysis","beautifulsoup","beautifulsoup4","fatality","labor","python","requests","scraper","scraper-api","workplace"],"latest_commit_sha":null,"homepage":"","language":"Python","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/jwc20.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2022-06-15T00:29:53.000Z","updated_at":"2024-08-26T13:40:32.000Z","dependencies_parsed_at":"2024-11-25T07:37:19.578Z","dependency_job_id":"efd2d3b8-3fdc-4d70-8bd7-37a26b2b062e","html_url":"https://github.com/jwc20/fcisapi","commit_stats":null,"previous_names":["jwc20/fcisapi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwc20%2Ffcisapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwc20%2Ffcisapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwc20%2Ffcisapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwc20%2Ffcisapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwc20","download_url":"https://codeload.github.com/jwc20/fcisapi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244542115,"owners_count":20469273,"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":["accidents-analysis","beautifulsoup","beautifulsoup4","fatality","labor","python","requests","scraper","scraper-api","workplace"],"created_at":"2024-11-25T07:37:03.976Z","updated_at":"2025-03-20T03:20:19.958Z","avatar_url":"https://github.com/jwc20.png","language":"Python","readme":"# fcis-api\n\n**Update: osha.org is blocking traffic from scrapers.**\n\n**TODO: Use splash headless browser and/or implement proxy to circumvent block.**\n\nA scraper API for Fatality and Catastrophe Investigation Summaries\n\n\n## Installation \nTo install, you can clone the project:\n```\ngit clone git@github.com:jwc20/fcis-api.git\ncd fcis-api\npip install -r requirement.txt\n```\n\n\n## Usage\n\n### Create client for searching accident reports\n\nYou can use description, abstract, and keyword words to search the reports.\\\nNote that \"abstract\" served the same purpose as \"description\" for older reports.\n\n```\nimport fcis\n\ndesc = [\"employee\"]\nabst = [\"employee\"]\nkeyw = [\"fire\"]\n\nclient = fcis.FCIS(descriptions=desc, keywords=keyw)\n```\n\n### Scrape accident reports\n\nTo search workplace accident report, type:\n```\nreports = client.get_accidents(p_show=100)\nprint(reports)\n```\n\nand you will get:\n\n```\n[{'accident_id': '141245.015',\n  'summary_url': 'https://www.osha.gov/pls/imis/accidentsearch.accident_detail?id=141245.015',\n  'summary_nr': '141245.01',\n  'event_date': '11/17/2021',\n  'report_id': '0213900',\n  'fatality': None,\n  'sic_url': None,\n  'sic_number': None,\n  'event_description': 'Employee Is Killed After Falling Through Elevator Shaft',\n  'fatility': 'X'},\n  ...\n```\n\n### Create client for getting details\n\nTo get details of individual report, type:\n```\nimport fcis\nclient = fcis.FCIS()\n```\n\n### Scrape accident details\n\nYou can use use the id of the accident details (found in searching the results) to get the details.\n\n```\ndetails = client.get_accident_details(ids=[\"570341\"])\nprint(details)\n```\n\nTo get:\n\n```\n{'accident_number': '570341',\n 'report_id': '0522300',\n 'event_date': '08/15/1984',\n 'inspection_url': 'establishment.inspection_detail?id=1667450',\n 'inspection_number': '1667450',\n 'open_date': '08/16/1984',\n 'sic_number': '4741',\n 'establishment_name': 'Mobile Tank Car Services',\n 'detail_description': 'THREE EMPLOYEES WERE CLEANING A RAILROAD TANK CAR CONTAINING RESIDUES OF COAL TAR LIGHT OIL, A FLAMMABLE LIQUID. ONE WAS ON TOP OF THE CAR, THE OTHER TWO WERE INSIDE. THEY WERE USING STEEL SHOVELS AND A NON EXPLOSION-PROOF LIGHT INSIDE THE CAR. THE VAPORS IGNITED, KILLING THE TWO EMPLOYEES INSIDE AND BURNING THE ONE ON TOP. THE OTHER EMPLOYEES WERE INJURED IN THE RESCUE ATTEMPT.',\n 'keywords': ['burn',\n  ' coal tar light oil',\n  ' flammable vapors',\n  ' railroad tank car',\n  ' cleaning',\n  ' explosion'],\n 'Employee': [{'Employee #': '1',\n   'Inspection': '1667450',\n   'Age': '',\n   'Sex': '',\n   'Degree': 'Fatality',\n   'Nature': 'Asphyxia',\n   'Occupation': 'Occupation not reported',\n   '': ''},\n  {'Employee #': '2',\n   'Inspection': '1667450',\n   'Age': '',\n   'Sex': '',\n   'Degree': 'Fatality',\n   'Nature': 'Asphyxia',\n   'Occupation': 'Occupation not reported',\n   '': ''},\n  ...\n}\n```\n\n### Requirements:\n- beautifulsoup4\n- lxml\n- requests\n\n### Links\n\n[Accident Search](https://www.osha.gov/pls/imis/accidentsearch.html)\n\n[Accident Investigation Search Help](https://www.osha.gov/help/accident-investigation)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwc20%2Ffcisapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwc20%2Ffcisapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwc20%2Ffcisapi/lists"}