HTTPError HTTP Error 500 INTERNAL SERVER ERROR

Problem description
django + mysql + collect.py
When using the collection.py script to collect information into the library, the URllib request is an error, but the data is already in the library

Traceback (most recent call last):
  File "collectRHEL.py", line 201, in <module>
    req = urllib2.urlopen(url, url_encode)
  File "/root/.pyenv/versions/2.7.11/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/root/.pyenv/versions/2.7.11/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/root/.pyenv/versions/2.7.11/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/root/.pyenv/versions/2.7.11/lib/python2.7/urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "/root/.pyenv/versions/2.7.11/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/root/.pyenv/versions/2.7.11/lib/python2.7/urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 500: INTERNAL SERVER ERROR

Solution idea, test method
First, clear the data in the library, modify some ORM field to make its length less than the length of the data to be inserted, which is bound to make an error, and then request with urllib and URllib2 respectively as the last test, but this time give enough length, and then test with urllib and urllib2 respectively
The test results
Whether it’s URllib or URllib2, it’s going to go wrong and whatever module you’re using, it’s going to be fine
conclusion

1. Determine the length of the database field in the ORM model
2. In fact, urllib.urlopen() or urllib2.urlopen() does not matter much

Read More: