经典段子爬取
一、经典段子
import re
import requests
"""
@author RansySun
@create 2019-07-22-9:16
"""
response = requests.get("https://ishuo.cn/")
data = response.text
res = re.findall('<li class="list_li">(.*?)</li>', data)
content_title_dic = {}
for i in res:
content = re.findall('<div class="content">(.*?)</div>', i)[0]
title = re.findall('<a href="/subject/.*?">(.*?)</a>', i)[0]
dic = re.findall('</a>(04.*?)</div>', i)[0]
content_title_dic[content] = [title, dic]
for i in content_title_dic.items():
print(f"{i[0]:<40}| {i[1]}")
# print(data)
# print(content)
# print(title)
# print(res)
在当下的阶段,必将由程序员来主导,甚至比以往更甚。