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:
- raise HTTPError(req.full_url, code, msg, hdrs, fp)urllib.error.HTTPError: HTTP Error 404: Not Found
- urllib2.HTTPError: HTTP Error 403: Forbidden
- Urllib2.httperror: http error 403: forbidden solution
- HTTP status 500 – internal server error (resolved) for Tomcat running project
- Python crawler: urllib.error.HTTPError : HTTP Error 404: Not Found
- Python crawler urllib.error.HTTPError : HTTP Error 418:
- asp.net HTTP error 500.24 – internal server error
- Resolve zuul the HTTP status 500 – internal server error error error displayed after startup
- IIS 7.5, ASP.NET MVC. HTTP error 500 (internal server error), but debugging does not enter the background, the browser only reports 500 errors
- urlopen error unknown url type:httpë/HTTP Error 400:Bad Request
- Drupal Internal Server Error 500
- python: HTTP Error 505: HTTP Version Not Supported
- NetworkError: 500 Internal Server Error
- Ies HTP to 500.19 – Internal Server
- Resolution of internal server error problem in diango project
- Solution of 500 internal server error reported by [SVN] TortoiseSVN
- Django debug = false internal server error 500
- gateway Internal Server Error 500 Invalid host: lb://xxxxxx
- Server (for example: HTTP) has a large number of time_ Solutions to wait
- Tomcat error: 500 The server encountered an internal error that prevented it from fulfilling this request