python - URL returns encoded value when parsed -
i using mechanize open url , i'm parsing beautifulsoup.
br = mechanize.browser() br.addheaders = [('user-agent', 'mozilla/5.0')] url = ('xyz.html') br.open(url) print br.response().read() #prints 4 special characters soup = beautifulsoup(br.response().read()) print soup #prints encoded data this problem doesn't occur if copy html file locally , parse it.
should decode/encode once retrieve through mechanize? if so, how should it?
Comments
Post a Comment