fromZhihu_oauthImportzhihuclient fromZhihu_oauth.exceptionImportneedcaptchaexceptionclient=zhihuclient ()Try: Client.login ('Email_or_phone','Password') Print(U"Landing Success!")exceptneedcaptchaexception:#Save verification Code and prompt for input, re-loginWith open ('A.gif','WB') as F:f.write (Client.get_captcha ()) Captcha= Input ('Please input captcha:') Client.login ('+8613872273541','z289784552', CAPTCHA)Print(U"Landing Success!") Client.save_token ('TOKEN.PKL')Get token
from __future__ ImportPrint_function#Print method using the Python3 fromZhihu_oauthImportzhihuclientImportReImportOSImporturllib.requestclient=zhihuclient ()#LoginClient.load_token ('TOKEN.PKL')#Load Token fileid = 46508954#https://www.zhihu.com/question/24400664 (How to look good is a kind of experience)Question =client.question (ID)Print(U"Questions:", Question.title)Print(U"Number of answers:", Question.answer_count) os.mkdir (Question.title+ U"(image)") path= Question.title + u"(image)"Index= 1#Picture Number forAnswerinchquestion.answers:content= Answer.content#Answer contentRe_compile = Re.compile (r'') img_lists=Re.findall (re_compile, content)if(img_lists): forImginchImg_lists:img_url= Img[0]#Picture URLUrllib.request.urlretrieve (Img_url, Path + u"/%d.jpg"%index)Print(U"successfully saved the first%d pictures"%index) Index+ = 1load token and read data
Python crawl to know all the pictures under the question