Python Urllib2 Http Error 500
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about
Urllib2.httperror Http Error 500 Internal Server Error Python
Stack Overflow the company Business Learn more about hiring developers or posting ads python httperror exception with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow python requests is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up I get HTTP 500 error when use python urllib2.open up vote 1 down vote favorite The code is like. The url is my blog and I'd like to fetch and backup my blog posts. Things goes well with my other blog posts but return 500 error with this one. usock = urlopen("http://xiaoshuaistudio.ycool.com/post.4606754.html") htmlSource = usock.read() usock.close() Can you help me figure out how to debug a HTTP 500 error? python urllib2 share|improve this question asked Dec 6 '11 at 18:33 hbrls 6261636 2 500 is a generic HTTP error. Read the server logs; this has nothing to do with urllib. –geoffspear Dec 6 '11 at 18:37 add a comment| 3 Answers 3 active oldest votes up vote 2 down vote A page content is loaded, and a 500 error is returned. But I myself can't read whether the page content is relevant. To avoid error on this specific page or website you could do (WARNING this is not very pretty) try: response = urlopen(url) content = response.read() except HTTPError, e: if e.getcode() == 500: content = e.read() else: raise share|improve this answer answered Dec 7 '11 at 15:30 Olivier H 394315 The following HTML parsing logic fails for the content from content = e.read(). So now I think something is wrong with the article itself. Maybe encoding error like @lostyzd suggested that server knows but human don't. Thanks for the advice. –hbrls Dec 8 '11 at 2:49 add a comment| up vote 0 down vote Take a look at the server logs on your web server. In general, error data will be safe on the server. It's not a good idea to dump error logs to users. share|improve this answer answered Dec 6 '11 at 18:36 M
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Traceback when http://stackoverflow.com/questions/8404938/i-get-http-500-error-when-use-python-urllib2-open I use urllib2, get a HTTP 500 error up vote 1 down vote favorite My code is like follows, but when it runs it throws an error. search_request = urllib2.Request(url,data=tmp_file_name,headers={'X-Requested-With':'WoMenShi888XMLHttpRequestWin'}) #print search_request.get_method() search_response = urllib2.urlopen(search_request) html_data = search_response.read() the error is: Traceback (most recent call last): File "xx_tmp.py", line 83, in
here for a quick overview of the site Help Center Detailed answers to any http://stackoverflow.com/questions/5632351/urllib2-httperror-http-error-500-internal-server-error questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring https://developer.ibm.com/answers/questions/172922/python-call-watson-question-and-answer-always-get.html developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is http error a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up urllib2.HTTPError: HTTP Error 500: Internal Server Error up vote 1 down vote favorite if data.find('!exploits') != -1: nick = data.split('!')[ 0 ].replace(':','') results = api.exploitdb.search(arg) sck.send('PRIVMSG ' + chan + " http error 500 :" + ' Results found: %s' % results['total'] + '\r\n') for exploit in results['matches'][:5]: sck.send('PRIVMSG ' + chan + "" + '%s:' % (exploit['description'] + '\r\n')) This little script searches exploit-db for known exploits, but the script seems not to work when I try to use it within IRC, but its fine when I run it alone, by alone I mean just this: from shodan import WebAPI SHODAN_API_KEY = "MY API KEY" api = WebAPI(SHODAN_API_KEY) results = api.exploitdb.search('PHP') print 'Results found: %s' % results['total'] for exploit in results['matches'][:5]: print '%s:' % (exploit['description']) that one works perfect, but I want to use it with IRC but I get this error: Traceback (most recent call last): File "C:\Users\Rabia\Documents\scripts\client.py", line 232, in
with a mandatory word, e.g. keyword2 keyword1 +keyword2 Questions excluding a word, e.g. keyword2 keyword1 -keyword2 Questions with a specific tag and keyword(s) +[tag1] keyword1 Questions with two or more specific tags and keyword(s) +[tag1] +[tag2] keyword1 To search for all posts by a user or all posts with a specific tag, start typing and choose from the suggestion list. Tags Spaces API Connect Appsecdev BPM Blockchain Bluemix CICS Cloud Analytics Cloud marketplace Content Services (ECM) Continuous Testing Courses DB2 LUW DataPower Decision Optimization DevOps Services Digital Experience Hadoop IBM Design IIDR ITOA InformationServer Integration Bus Internet of Things LinuxONE MDM Mainframe Messaging Node.js ODM Open Predictive Analytics PureData for Analytics Push Run Book Automation Storage Streamsdev Swift UrbanCode WASdev WSRR Watson dW Answers Help dW Premium developerWorks Team Watson Health More Users Badges Ask a question python call Watson Question and Answer always get HTTP 500 error. not sure why... Question by DonnieGou ( 18) | Jan 29, 2015 at 11:26 PM pythonwatson question and aurllib2 import os import urllib import urllib2 import json import base64 questiontext = 'what caused hurt?' qaa_url = 'https://watson.ihost.com/instance/67/deepqa/v1/question' qaa_username = 'wat3_approver3' qaa_password = 'hF5EFmqZ' question_sub_dict = {} question_sub_dict['questionText'] = questiontext question_dict = {} question_dict['question'] = question_sub_dict question_json = json.dumps(question_dict) auth ='Basic ' + base64.b64encode( qaa_username+':'+ qaa_password ) #try urllib2 passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm() passmgr.add_password(None,qaa_url,qaa_username,qaa_password) urllib2.install_opener(urllib2.build_opener(urllib2.HTTPBasicAuthHandler(passmgr))) req = urllib2.Request(qaa_url,pa