I had some Python 2 code as follows (pardon the indentation):
def getZacksRating(symbol):
c = httplib.HTTPSConnection("www.zacks.com")
c.request("GET", "/stock/quote/"+symbol)
response = c.getresponse()
data = response.read()
ratingPart = data.split('<p class="rank_view">')[1]
result = ratingPart.partition("<span")[0].strip()
return result
print getZacksRating("AAPL")
So I changed it to (adding the b' ').
import http
def getZacksRating(symbol):
c = http.client.HTTPSConnection("www.zacks.com")
c.request("GET", "/stock/quote/"+symbol)
response = c.getresponse()
data = response.read()
ratingPart = data.split(b'<p class="rank_view">')[1]
result = ratingPart.partition(b"<span")[0].strip()
return result
print(getZacksRating('AAPL'))
But it getting printed as below:
print(getZacksRating('AAPL'))
b'Strong Buy'
I don't wish to see the b' ' in my output. Just want to see strong Buy being printed.