Environment: Python3.6
#!/usr/bin/env python3#-*-coding:utf-8-*-#version:3.6.4__author__ = ' 杜文涛 ' import Requestsimport jsondef get_json_dic (URL): global dict_json response = requests.get (Url=url) json_response = Response.content.decode () #获取r的文本 is a JSON string dict_json = Json.loads (json_response) # convert JSON string to dic Dictionary object return dict_jsondef get_joke (Dict_json): print (len (dict_json[' data ' [' Data '])) for i in range (1,20): conture = Input (' Continue, y/n ') if conture == ' Y ' or conture == ' y ': joke = dict_json[' data ' [' Data '][i][' group '][' Text '] if i == 19: dict_json = {} conture print (joke) else: exit () def get_max_time (Dic_json): global max_time max_time = dict_json[' data ' [' Max_time '] return max_timeif __ name__ == ' __main__ ': max_time = 1519404642 url = ' Http://www.neihanshequ.com/joke/?is_json=1&app_name=neihanshequ_web&max_time= ' + str (max_time)   &NBsp; get_json_dic (URL) get_max_time (Dic_json=dict_json) get _joke (Dict_json=dict_json) while True: url = ' Http://www.neihanshequ.com/joke/?is_json=1&app_name=neihanshequ_web&max_time= ' + str (max_time) get_json_dic (URL) get_max_time (Dic_json=dict_json) Get_joke (Dict_json=dict_json) print (URL)
Public Number:
Python crawls the jokes in the content