Giter Site home page Giter Site logo

arthurtyukayev / python-safer Goto Github PK

View Code? Open in Web Editor NEW
20.0 9.0 20.0 32 KB

A web scraping API written in Python to fetch data from the Department of Transportation's https://safer.fmcsa.dot.gov

License: MIT License

Python 100.00%
python government usdot safer company-snapshot fmcsa

python-safer's People

Contributors

arthurtyukayev avatar justjay-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-safer's Issues

ValueError: time data does not match format '%m/%d/%Y'

Calling get_by_usdot_number with 3279824 throws a value error. For some reason it's pulling the Inspections/Crashes In US table instead of the Safety Rating table. It seems to only happen for random DOTs and I'm not sure where the mismatch is in the UI for this to happen.

Traceback (most recent call last):
  File ".../CompanySnapshot.py", line 20, in <module>
    getCarrierInfoByDOT(3279824)
  File ".../CompanySnapshot.py", line 6, in getCarrierInfoByDOT
    company = client.get_by_usdot_number(dot)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../venv/lib/python3.11/site-packages/safer/search.py", line 83, in get_by_usdot_number
    return Company(
           ^^^^^^^^
  File ".../venv/lib/python3.11/site-packages/safer/results.py", line 50, in __init__
    self.__safety_rating_date = datetime.strptime(data['safety_review_date'], "%m/%d/%Y") if data[
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/_strptime.py", line 568, in _strptime_datetime
    tt, fraction, gmtoff_fraction = _strptime(data_string, format)
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/_strptime.py", line 349, in _strptime
    raise ValueError("time data %r does not match format %r" %
ValueError: time data '41' does not match format '%m/%d/%Y'

Question about data results

It seems that as soon as a number is entered into the system you can use the portal and search it. It will only return the company name. But it seems about after 24 hours when searching https://safer.fmcsa.dot.gov/CompanySnapshot.aspx it will then contain all the info about the USDOT number. Is there a way to get this data immediately without having to wait 24 hours?

Issue importing safer (macosx)

Big fan of this as their APIs are not documented so great work. However:

ModuleNotFoundError: No module named 'safer' ```

On Python 3.7.4. MacOSX. Installed using `pip install python-safer` is instructed. 

when I run a `pip list | grep safer` it only shows python-safer. 

Now, when I try to run with ```import python-safer``` etc I get this: 

File "main.py", line 1
 from python-safer import CompanySnapshot
            ^
SyntaxError: invalid syntax

IndexError

result error: IndexError: No value at index 0.
for value "python"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.