Skip to content

Commit 4700e75

Browse files
committed
Merge pull request egrcc#27 from LuoZijun/patch-9
Update auth.py
2 parents 0d01e2a + caa3aff commit 4700e75

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

auth.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ def search_xsrf():
112112
return results[0]
113113

114114
def build_form(account, password):
115-
account_type = "email"
116-
if re.match(r"^\d{11}$", account): account_type = "phone"
115+
if re.match(r"^1\d{10}$", account): account_type = "phone_num"
117116
elif re.match(r"^\S+\@\S+\.\S+$", account): account_type = "email"
118117
else: raise AccountError(u"帐号类型错误")
119118

@@ -124,7 +123,10 @@ def build_form(account, password):
124123
return form
125124

126125
def upload_form(form):
127-
url = "http://www.zhihu.com/login/email"
126+
if "email" in form: url = "http://www.zhihu.com/login/email"
127+
elif "phone_num" in form: url = "http://www.zhihu.com/login/phone_num"
128+
else: raise ValueError(u"账号类型错误")
129+
128130
headers = {
129131
'User-Agent': "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36",
130132
'Host': "www.zhihu.com",

0 commit comments

Comments
 (0)