def LoadPage(self, myUrl):
user_agent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
headers = {'User-Agent': user_agent, 'Accept': accept}
print self.base_url + myUrl
req = urllib2.Request(self.base_url+myUrl, headers=headers)
myResponse = urllib2.urlopen(req)
myPage = myResponse.read()
#print myPage
# encode?????unicode?????????????
# decode????????????????unicode??
unicodePage = myPage.decode("gb2312", 'ignore').encode('utf-8', 'ignore')
# print unicodePage
return unicodePage
评论列表
文章目录