经典段子爬取

一、经典段子

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)

posted @ 2019-07-23 15:03  RandySun  阅读(155)  评论(0编辑  收藏  举报