Code4HR / va-circuit-court-search

Virginia Courts Case Information - Statewide Searches ARE Possible
http://vacircuitcourtsearch.com/
MIT License
11 stars 7 forks source link

AttributeError: 'NoneType' object has no attribute 'find_all' #5

Closed prgr4m closed 9 years ago

prgr4m commented 9 years ago

From fresh check out using pyenv 2.7.8

$python courts.py
* Running on http://0.0.0.0:5000/
* Restarting with reloader
127.0.0.1 - - [26/Nov/2014 18:01:46] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [26/Nov/2014 18:01:56] "GET /search/Smith,%20John HTTP/1.1" 200 -
127.0.0.1 - - [26/Nov/2014 18:01:58] "GET /search/SMITH,%20JOHN/court/001C3Accomack%20Circuit%20Court HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
  return self.wsgi_app(environ, start_response)
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
  response = self.make_response(self.handle_exception(e))
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
  reraise(exc_type, exc_value, tb)
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
  response = self.full_dispatch_request()
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
  rv = self.handle_user_exception(e)
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
  reraise(exc_type, exc_value, tb)
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
  rv = self.dispatch_request()
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
  return self.view_functions[rule.endpoint](**req.view_args)
File "/home/prgr4m/Projects/Civic/original/courts.py", line 147, in searchCourt
courtId, 'R')
File "/home/prgr4m/Projects/Civic/original/courts.py", line 53, in lookupCases
  done = getCases(BeautifulSoup(html), name, cases)
File "/home/prgr4m/Projects/Civic/original/courts.py", line 17, in getCases
  for row in html.find(class_="nameList").find_all('tr'):
AttributeError: 'NoneType' object has no attribute 'find_all'
127.0.0.1 - - [26/Nov/2014 18:01:59] "GET /search/SMITH,%20JOHN/court/003C1Albemarle%20Circuit%20Court HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
  return self.wsgi_app(environ, start_response)
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
  response = self.make_response(self.handle_exception(e))
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
  reraise(exc_type, exc_value, tb)
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
  response = self.full_dispatch_request()
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
  rv = self.handle_user_exception(e)
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
  reraise(exc_type, exc_value, tb)
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
  rv = self.dispatch_request()
File "/home/prgr4m/.virtualenvs/va-circuit-court-search_2.7.8/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
  return self.view_functions[rule.endpoint](**req.view_args)
File "/home/prgr4m/Projects/Civic/original/courts.py", line 147, in searchCourt
courtId, 'R')
File "/home/prgr4m/Projects/Civic/original/courts.py", line 53, in lookupCases
  done = getCases(BeautifulSoup(html), name, cases)
File "/home/prgr4m/Projects/Civic/original/courts.py", line 17, in getCases
  for row in html.find(class_="nameList").find_all('tr'):
AttributeError: 'NoneType' object has no attribute 'find_all'

Using pyenv 3.4.2:

$ python courts.py
Traceback (most recent call last):
  File "courts.py", line 2, in <module>
    import cookielib
ImportError: No module named 'cookielib'
bschoenfeld commented 9 years ago

Definitely use 2.7. Very strange error. Looks like the table with the results is missing. Can you modify the code to print the result of the .read() call before it's passed into the BeautifulSoup object? That will show the raw HTML being returned by the request and we can see what is different about it.

prgr4m commented 9 years ago

Fixed issue. Python 2.x will only be supported until 2020. Yes, that's a ways away but knowing how things progress, might I suggest writing code that works for both? Like using requests as the http client (works for both 2.x and 3.x) and handles cookies for you? Yes, urllib and urllib2 is standard (a little dated) but its just urllib in py3. I personally prefer standard libs but in this particular project and knowing how slow upgrade paths can be in gov't, it wouldn't be a bad move at all to move to requests.