lv19980523
苦瓜亦叫半生瓜
2017-08-29 04:46

模拟登录时UnicodeEncodeError: 'latin-1'问题该如何解决?

  • python
  • unicodeencodeerror
  • 模拟登录

  例如:

data =  urllib.parse.urlencode(values)
postdata = data.decode('utf-8')

req = requests.post(url,postdata,headers=headers)

  以下是源代码:

from urllib import request
from urllib import parse
import requests
import time

url = 'http://mail.163.com/'

post_url = 'https://dl.reg.163.com/l'

headers={
        'User-Agent' : 'Mozilla/5.0 (X11; Ubuntu; Linu…) Gecko/20100101 Firefox/55.0',
        'Host':'gzcp.127.net',
        'Accept-Language':'zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3',
        'Accept-Encoding':'gzip, deflate',
        'Referer':url,
        'Connection':'keep-alive'
        }

time = int(time.time())
print(time)
values = {
        'un':'lv19980523@163.com',
        'pw':'WrNlN11lmXwrJkrg7UdNPH1u6FEMtRfddaDd16BbYxngoW6B04l2WgC8k0wlOkvRm6xFfU',
        'pd':'mail163',
        'l' :'0',
        'd' :'10',
        't' :time,
        'pkid':'CvViHzl',
        'domains'   :'163.com',
        'tk':'189b96b1fa4a797b184868be3793daf0',
        'pwdKeyUp':'1',
        'topURL':'http://mail.163.com/'
            }
data = parse.urlencode(values).encode('utf-8')

req = requests.post(post_url,data,headers=headers)

response = request.urlopen(req)

print(response)
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐