# coding:utf-8 from urllib.request import urlretrieve import threading import requests from bs4 import BeautifulSoup from datetime import datetime import pymysql import random import json import time number=0 def GetArticel(): max_time = 1519404642 data = requests.get("http://www.neihanshequ.com/joke/?is_json=1&app_name=neihanshequ_web&max_time=" + str(max_time)) soup = BeautifulSoup(data.text, ‘html5lib‘) #print(soup.select_one(‘body‘).get_text()) global number jsondata=json.loads(str(soup.select_one(‘body‘).get_text())) articleList=jsondata[‘data‘][‘data‘] f = open("article.txt", ‘a‘,encoding=‘utf-8‘) for item in articleList: number+=1 #print(number) f.write(item[‘group‘][‘content‘]+‘\n\n\n‘) print(number) f.close() # print(count) # print(item) if __name__ == ‘__main__‘: for i in range(1,10): print(i) #GetArticel() #time.sleep(1)