File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,8 +112,7 @@ def search_xsrf():
112112 return results [0 ]
113113
114114def 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
126125def 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" ,
You can’t perform that action at this time.
0 commit comments