Skip to content

Commit

Permalink
修复验证码错误的 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
egrcc committed Apr 16, 2016
1 parent 59cbd9c commit 494afb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 8 additions & 5 deletions auth.py
Expand Up @@ -66,8 +66,8 @@ def __init__(self, message):


def download_captcha():
url = "http://www.zhihu.com/captcha.gif"
r = requests.get(url, params={"r": random.random()} )
url = "https://www.zhihu.com/captcha.gif"
r = requests.get(url, params={"r": random.random(), "type": "login"} )
if int(r.status_code) != 200:
raise NetworkError(u"验证码请求失败")
image_name = u"verify." + r.headers['content-type'].split("/")[1]
Expand Down Expand Up @@ -124,9 +124,12 @@ def build_form(account, password):
return form

def upload_form(form):
if "email" in form: url = "http://www.zhihu.com/login/email"
elif "phone_num" in form: url = "http://www.zhihu.com/login/phone_num"
else: raise ValueError(u"账号类型错误")
if "email" in form:
url = "https://www.zhihu.com/login/email"
elif "phone_num" in form:
url = "https://www.zhihu.com/login/phone_num"
else:
raise ValueError(u"账号类型错误")

headers = {
'User-Agent': "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36",
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
@@ -1,4 +1,5 @@
requests
beautifulsoup4
html2text
termcolor
termcolor
lxml

0 comments on commit 494afb1

Please sign in to comment.