Although there are not many 1,000 fans, it is also affirmation of my study for more than half a year. I am currently studying in graduate school and have no extra income. Don't think it is too small for the judges. When I work in the future, I will give the judges more and better. Welfare~
The random lottery draw is of course using our python crawler. Take a previous article as an example to write the code.
import requests import json import random def get_user(url): html = requests.get(url) json_data = json.loads(html.text) comments = json_data['comments'] for comment in comments: nickname = comment['user']['nickname'] user_list.append(nickname) if __name__ =='__main__': user_list = [] url ='http://www.jianshu.com/notes/9315244/comments?page=1' html = requests.get(url) json_data = json.loads(html.text) total_pages = json_data['total_pages'] urls = ['http://www.jianshu.com/notes/9315244/comments?page={}'.format(str(i)) for i in range(1,int(total_pages)+1)] for url in urls: get_user(url) user_list = set(user_list) print(random.sample(user_list,5))
The result is released:
I will contact all the winning fans~ Thank you for your support