Unicode编码使用mechanize登录网站时出错

时间:2017-05-15 16:50:05

标签: python unicode web-scraping mechanize

我正在使用mechanize登录网站https://www.patientslikeme.com但我收到错误:

UnicodeEncodeError: 'ascii' codec can't encode character u'\u2713' in position 0: ordinal not in range(128).

请回复如何解决这个问题。

代码:

import mechanize
import cookielib

br = mechanize.Browser()
br.set_handle_robots( False )

cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
br.addheaders = [('User-agent', 'Firefox')]

br.open('https://www.patientslikeme.com/users/sign_in')
br.select_form( nr=1)

br['user[email_or_login]'] = 'divyat'
br['user[password]']= 'nothing'

logged_in= br.submit()
logincheck= logged_in.read()

错误是由行logged_in= br.submit()

引起的

0 个答案:

没有答案