{"id":24526128,"url":"https://github.com/arthurtyukayev/python-safer","last_synced_at":"2025-04-14T14:34:02.327Z","repository":{"id":25177968,"uuid":"103175473","full_name":"arthurtyukayev/python-safer","owner":"arthurtyukayev","description":"A web scraping API written in Python to fetch data from the Department of Transportation's https://safer.fmcsa.dot.gov","archived":false,"fork":false,"pushed_at":"2024-03-23T17:19:45.000Z","size":32,"stargazers_count":20,"open_issues_count":1,"forks_count":20,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-04-29T18:23:34.376Z","etag":null,"topics":["company-snapshot","fmcsa","government","python","safer","usdot"],"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/arthurtyukayev.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":"2017-09-11T18:54:14.000Z","updated_at":"2024-04-04T14:54:54.000Z","dependencies_parsed_at":"2025-01-04T20:41:08.757Z","dependency_job_id":null,"html_url":"https://github.com/arthurtyukayev/python-safer","commit_stats":{"total_commits":30,"total_committers":6,"mean_commits":5.0,"dds":0.6666666666666667,"last_synced_commit":"553be3662f6b8bb6a45a9026c635eaf400e1b4ca"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurtyukayev%2Fpython-safer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurtyukayev%2Fpython-safer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurtyukayev%2Fpython-safer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arthurtyukayev%2Fpython-safer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arthurtyukayev","download_url":"https://codeload.github.com/arthurtyukayev/python-safer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248897697,"owners_count":21179632,"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":["company-snapshot","fmcsa","government","python","safer","usdot"],"created_at":"2025-01-22T05:32:44.466Z","updated_at":"2025-04-14T14:34:02.294Z","avatar_url":"https://github.com/arthurtyukayev.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-safer\n[![PyPI version](https://badge.fury.io/py/python-safer.svg)](https://badge.fury.io/py/python-safer)\n\npython-safer is an web scraping API wrapper written in Python to fetch data from the [Department of Transportation's Safety and Fitness Electronic Records System](https://safer.fmcsa.dot.gov/CompanySnapshot.aspx).\n\n### If you plan to use this package in any capacity, it's highly recommended to cache all of the results you get from the SAFER website. The SAFER website is highly unreliable and will randomly go down.\n\nHere is how you search for companies using python-safer\n\n```python\nfrom safer import CompanySnapshot\n\nclient = CompanySnapshot()\n\nresults = client.search('python')\nfor company in results:\n    print(company)\n```\n\n```console\n\u003cSearchResult PYTHON CORPORATION (698887) from  Lacombe, LA\u003e\n\u003cSearchResult PYTHON PRESSURE PUMPING LLC (2346443) from  Ada, OK\u003e\n\u003cSearchResult PYTHON SERVICES LLC (918670) from  Brighton, CO\u003e\n\u003cSearchResult PYTHON TRANSPORT CORP (2379682) from  Dania Beach, FL\u003e\n\u003cSearchResult PYTHON TRANSPORTS LLC (2642177) from  Fort Worth, TX\u003e\n\u003cSearchResult PYTHON'S OF ST CLOUD INC (604262) from  St Cloud, MN\u003e\n```\n\n```python\ncompany = results[0].get_company_snapshot()\nprint(company.legal_name)\n```\n```console\nPYTHON CORPORATION\n```\n\n\n### Todo\n\n- Write some tests.\n\n### Issues\n\nIf there are any problems, just open issue.\n\n### Installation\n\n##### Prerequisites\n[lxml](http://lxml.de) - the C bindings are needed as well. Just follow the installation instructions, should be fine.\n##### Install using pip\n\n```python\npip install python-safer\n```\n\n### Usage\n\nThis was written with Python 3.5, but it will probably work for any Python 3 version\n\n**Be prepared to wait for results, the SAFER CompanySnapshot website is very slow, and half the time it's down.**\n\n**Import and create CompanySnapshot**\n```python\nfrom safer import CompanySnapshot\n\nclient = CompanySnapshot()\n```\n\n**Search by Name**\n\nSearching by name will return a SearchResultSet object that can be iterated through,\neach item in the SearchResultSet is a SearchResult object, to get the Company Snapshot of that object\nyou can call `get_company_snapshot()`\n```python\nfor company in client.search('python'):\n    company.get_company_snapshot()\n```\nGetting the company snapshot will return a Company Object.\n\n**Search by USDOT Number**\n\nSearching by USDOT will return a Company object or raise a `CompanySnapshotNotFoundException` exception for that USDOT.\n\n```python\ncompany = client.get_by_usdot_number(698887)\nprint(company.to_json())\n```\n```console\n{\n  \"operation_classification\": [\n    \"Private(Property)\"\n  ],\n  \"physical_address\": \"29279 HWY 190 LACOMBE, LA  70445\",\n  \"united_states_inspections\": {\n    \"hazmat\": {\n      \"out_of_service\": \"0\",\n      \"inspections\": \"0\",\n      \"out_of_service_percent\": \"0%\",\n      \"national_average\": \"4.50%\"\n    },\n    \"driver\": {\n      \"out_of_service\": \"0\",\n      \"inspections\": \"0\",\n      \"out_of_service_percent\": \"0%\",\n      \"national_average\": \"5.51%\"\n    },\n    \"iep\": {\n      \"out_of_service\": 0,\n      \"inspections\": 0,\n      \"out_of_service_percent\": \"0%\",\n      \"national_average\": \"N/A\"\n    },\n    \"vehicle\": {\n      \"out_of_service\": \"0\",\n      \"inspections\": \"0\",\n      \"out_of_service_percent\": \"0%\",\n      \"national_average\": \"20.72%\"\n    }\n  },\n  \"state_carrier_id\": \"\",\n  \"mc_mx_ff_numbers\": null,\n  \"out_of_service_date\": null,\n  \"mcs_150_form_date\": \"05/13/2016\",\n  \"safety_rating\": null,\n  \"carrier_operation\": [\n    \"Interstate\"\n  ],\n  \"hm_shipper_operation\": null,\n  \"safety_review_date\": null,\n  \"canada_crashes\": {\n    \"injury\": 0,\n    \"total\": 0,\n    \"fatal\": 0,\n    \"tow\": 0\n  },\n  \"mcs_150_mileage_year\": {\n    \"year\": 2015,\n    \"mileage\": 200000\n  },\n  \"mailing_address\": \"PO BOX 790 LACOMBE, LA  70445\",\n  \"power_units\": 8,\n  \"dba_name\": \"\",\n  \"entity_type\": \"CARRIER\",\n  \"safety_rating_date\": null,\n  \"safety_type\": null,\n  \"duns_number\": null,\n  \"drivers\": 7,\n  \"us_inspections\": {\n    \"hazmat\": {\n      \"out_of_service\": 0,\n      \"inspections\": 0,\n      \"out_of_service_percent\": \"0%\",\n      \"national_average\": \"4.50%\"\n    },\n    \"vehicle\": {\n      \"out_of_service\": 0,\n      \"inspections\": 0,\n      \"out_of_service_percent\": \"0%\",\n      \"national_average\": \"20.72%\"\n    },\n    \"iep\": {\n      \"out_of_service\": 0,\n      \"inspections\": 0,\n      \"out_of_service_percent\": \"0%\",\n      \"national_average\": \"N/A\"\n    },\n    \"driver\": {\n      \"out_of_service\": 0,\n      \"inspections\": 0,\n      \"out_of_service_percent\": \"0%\",\n      \"national_average\": \"5.51%\"\n    }\n  },\n  \"united_states_crashes\": {\n    \"injury\": 0,\n    \"total\": 0,\n    \"fatal\": 0,\n    \"tow\": 0\n  },\n  \"phone\": \"(985) 882-6101\",\n  \"usdot\": \"698887\",\n  \"url\": \"http://www.safersys.org/query.asp?searchtype=ANY\u0026query_type=queryCarrierSnapshot\u0026query_param=USDOT\u0026original_query_param=NAME\u0026query_string=698887\",\n  \"legal_name\": \"PYTHON CORPORATION\",\n  \"latest_update\": \"09/12/2017\",\n  \"cargo_carried\": [\n    \"Building Materials\"\n  ],\n  \"operating_status\": \"ACTIVE\",\n  \"canada_inspections\": {\n    \"vehicle\": {\n      \"out_of_service\": 0,\n      \"inspections\": 0,\n      \"out_of_service_percent\": \"0%\"\n    },\n    \"driver\": {\n      \"out_of_service\": 0,\n      \"inspections\": 0,\n      \"out_of_service_percent\": \"0%\"\n    }\n  }\n}\n```\n\n**Viewing Company Snapshots in a web browser**\n\nUsing the `open_url()` function on a Company object, will open the Company Snapshot on the SAFER website.\n\n```python\ncompany = client.get_by_usdot_number(698887)\ncompany.open_url()\n```\n\n**Company Object Properties**\n```python\ncompany.legal_name\n```\n```console\n'PYTHON CORPORATION'\n```\n```python\ncompany.drivers\n```\n```console\n7\n```\n```python\ncompany.power_units\n```\n```console\n8\n```\n```python\ncompany.phone_number\n```\n```console\n'(985) 882-6101'\n```\n\nThere is more, just look at the source code. However all values that are shown on the Company Snapshot website are available in the Company class.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farthurtyukayev%2Fpython-safer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farthurtyukayev%2Fpython-safer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farthurtyukayev%2Fpython-safer/lists"}