Python crawls the jokes in the content

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.