Clearing error NoneType has no encode method in fetch_url()

When you have post_data = None, you can't post_data.encode('ASCII')
I have added a conditional sentence to evaluate post_data, to use urllib.request.urlopen(url) when post_data is non-existent.