知乎热评爬虫程序,由吾爱大神原创制作分享的一个爬虫程序单exe文件版本,可以免费爬取知乎上的一些热评信息,只需要复制自己的知乎cookie链接即可一键开始爬取,可以按照热度榜来进行爬虫搜索,将评论信息存储到本地进行浏览。本次带来知乎热评爬虫程序资源下载,经常浏览知乎的朋友们可以试试。

一键爬取知乎热评信息
支持按搜索榜来进行爬取操作
可下载到本地进行浏览
# -*- coding:utf-8 -*-
import requests
from lxml import etree
import pandas as pd
import json
from openpyxl import Workbook
from openpyxl.utils.dataframe import dataframe_to_rows
import datetime
from PySide2.QtWidgets import QApplication, QMessageBox,QFileDialog,QHeaderView,QAbstractItemView,QTableWidgetItem
from PySide2.QtUiTools import QUiLoader
import threading
import os
from PySide2.QtGui import QIcon
class Download:
def __init__(self):
self.ui = QUiLoader().load('知乎.ui')
self.ui.cookies_button.clicked.connect(self.get_cookies)
self.ui.catch_button.clicked.connect(self.find_hot)
self.ui.save_button.clicked.connect(self.save2)
self.cookies = 0000
self.df = 0000
self.ui.hot_list.horizontalHeader().resizeSection(0, 80)
self.ui.hot_list.horizontalHeader().resizeSection(1, 400)
# self.tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.ui.hot_list.setEditTriggers(QAbstractItemView.NoEditTriggers)
self.hot_list = 0000
#self.ui.hot_list.setEditTriggers(QAbstractItemView.NoEditTriggers)
def get_cookies(self):
if len(threading.enumerate()) >= 2:
QMessageBox.about(self.ui,
'警告',
'正在下载!!'
)
return
self.ui.cookies_edit.clear()
self.ui.cookies_edit.paste()
self.cookies = self.ui.cookies_edit.toPlainText()
def find_hot(self):
if len(threading.enumerate()) >= 2:
QMessageBox.about(self.ui,
'警告',
'正在下载!!'
)
return
if self.cookies == 0000:
QMessageBox.about(self.ui,
'警告',
'你还没有粘贴进去cookies!下载个锤子'
)
return
rows = self.ui.hot_list.rowCount()
for row in range(rows):
self.ui.hot_list.removeRow(0)
url = 'https://www.zhihu.com/hot'
headers = {
'user-agent': '''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36''',
'cookie': self.cookies
}
try:
response = requests.get(url, headers=headers)
except:
self.ui.hot_list.insertRow(0)
item = QTableWidgetItem('错误!')
self.ui.hot_list.setItem(0, 0, item)
item = QTableWidgetItem('cookies可能有误,无误的话就重启软件试试~')
self.ui.hot_list.setItem(0, 1, item)
return
html = response.text
html = etree.HTML(html)
url_list = html.xpath('''//div[@class='HotList-list']/section/div[@class="HotItem-content"]/a/@href''')
title_list = html.xpath('''//div[@class='HotList-list']/section/div[@class="HotItem-content"]/a/@title''')
hot_nums = html.xpath('''//div[@class='HotList-list']/section/div[@class="HotItem-content"]/div/text()''')
data = {
'url': url_list,
'title': title_list,
'hot': hot_nums
}
df = pd.DataFrame(data)
try:
df1 = pd.DataFrame(list(df['url'].str.split('/')))
except AttributeError:
self.ui.hot_list.insertRow(0)
item = QTableWidgetItem('错误!')
self.ui.hot_list.setItem(0, 0, item)
item = QTableWidgetItem('你可拉倒吧,cookies明显有误!')
self.ui.hot_list.setItem(0, 1, item)
return
df = df.join(df1[[3, 4]])
df = df.rename(columns={3: 'isque', 4: 'pid'})
df = df[df['isque'] == 'question']
for i in range(len(df)):
dftemp = df.loc[i]
row = self.ui.hot_list.rowCount()
self.ui.hot_list.insertRow(row)
item = QTableWidgetItem(str(dftemp['hot']))
self.ui.hot_list.setItem(row, 0, item)
item = QTableWidgetItem(str(dftemp['title']))
self.ui.hot_list.setItem(row, 1, item)
self.df = df
def save2(self):
if len(threading.enumerate()) >= 2:
QMessageBox.about(self.ui,
'警告',
'正在下载!!'
)
return
print(type(self.df))
try:
if self.df == 0000:
QMessageBox.about(self.ui,
'警告',
'你还没有获取,保存个锤子',
)
return
except ValueError:
pass
df = self.df
filePath = QFileDialog.getExistingDirectory(self.ui, "选择存储路径")
if filePath == '':
return
def get_comments(df,cookies):
pid = df['pid']
comm_list = []
print(f'正在爬pid={pid}')
for i in range(1, 100, 20):
print(f'其中第{i}个')
url = f'https://www.zhihu.com/api/v4/questions/{pid}/answers?include=data%5B%2A%5D.is_normal%2Cadmin_closed_comment%2Creward_info%2Cis_collapsed%2Cannotation_action%2Cannotation_detail%2Ccollapse_reason%2Cis_sticky%2Ccollapsed_by%2Csuggest_edit%2Ccomment_count%2Ccan_comment%2Ccontent%2Ceditable_content%2Cvoteup_count%2Creshipment_settings%2Ccomment_permission%2Ccreated_time%2Cupdated_time%2Creview_info%2Crelevant_info%2Cquestion%2Cexcerpt%2Crelationship.is_authorized%2Cis_author%2Cvoting%2Cis_thanked%2Cis_nothelp%2Cis_labeled%2Cis_recognized%2Cpaid_info%2Cpaid_info_content%3Bdata%5B%2A%5D.mark_infos%5B%2A%5D.url%3Bdata%5B%2A%5D.author.follower_count%2Cbadge%5B%2A%5D.topics&limit=20&offset={i}&platform=desktop&sort_by=default'
headers = {
'user-agent': '''Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36''',
'cookie': cookies
}
res = requests.get(url, headers=headers)
res.encoding = 'utf-8'
html = res.text
data = json.loads(html)['data']
if data == []:
break
df2 = pd.DataFrame(data)
df3 = pd.DataFrame(list(df2['author']))
df3 = df3[['name', 'url_token', 'user_type', 'headline']]
df4 = df3.merge(df2[['content', 'voteup_count', 'comment_count']], left_index=True, right_index=True)
comm_list.append(df4)
a = comm_list[0]
for j in comm_list[1:]:
a = a.append(j, ignore_index=True)
return a
def thr(df,ui,cookies):
hot_list = []
for i in df.index:
ui.download_edit.append(f'正在爬第{i + 1}个')
ui.download_edit.ensureCursorVisible()
comments = get_comments(df.loc[i],cookies)
hot_list.append(comments)
#break
ui.download_edit.append('终于下载完了,正在保存')
ui.download_edit.ensureCursorVisible()
wb = Workbook()
ws = wb.active
for row in dataframe_to_rows(df[['url', 'title', 'hot']], index=False, header=True):
ws.append(row)
count = 1
for df0 in hot_list:
title = f'排行第{count}'
wb.create_sheet(title=title)
sheet = wb[title]
for r in dataframe_to_rows(df0, index=False, header=True):
sheet.append(r)
count += 1
file_time = str(datetime.datetime.now())[:-7]
file_time = file_time.replace(":", '-')
file_name = f"知乎热评{file_time}.xlsx"
wb.save(filePath + '\\' + file_name)
# QMessageBox.about(ui,
# '通知',
# '久等了,终于下载完成了'
# )
t1 = threading.Thread(target=thr,args=[df,self.ui,self.cookies])
t1.start()
app = QApplication([])
app.setWindowIcon(QIcon('0.png'))
d = Download()
d.ui.show()
app.exec_()
os._exit(0)
知乎近30W人担心的问题,一个人是怎样废掉的?警惕这些情况
对于这个问题,要从两点开始回答,怎样的人才算是废掉?他/她是怎样变成这个样子的?
1.染上了严重的恶习
为什么说染上了严重的恶习就算是废掉了?因为恶习会一点一点侵蚀一个人,导致精神迷幻,严重者导致死亡。
这里所指的恶习就是黄赌毒,这三样是每个人坚决不能碰的东西,虽然在中华上下五千年的历史长河中,这三样恶习从来都没有绝迹过,总是有人想要去尝试一番,这也是他们的可怕之处。
黄赌毒会严重影响一个人的心智,侵蚀价值观,道德底线也会不断地降低,最终的结果就是丧失人生价值,失去人生该有的幸福体验。
2.习惯于被动吸收,一切事物逆来顺受
如果硬是要说一个具体的词来描述,“上进心”会贴切一些,一个人丧失了主动思考的能力,对于所有的信息都习惯于被动吸收,从不主动做某件事情。对于外界,无论好事还是坏事,一切都逆来顺受,如同行尸走肉一般浑浑噩噩的生活。
人和植物的基本区别是思想,就是因为有了思想,人才能在进化的过程中变得越来越优秀。
3.封闭社交,拒绝接受新鲜事物
这就好比一个上世纪早期的人,来到现在这个社会,如果拒绝接受任何新鲜事物,并且封闭自己的社交,那么他很难存活下来。
开发者其他应用

七猫免费阅读小说最新版41.6M234049人在玩七猫免费阅读小说下载安装app,七猫免费阅读小说app不一样的小说阅读神器,这里有着海量丰富小说应用资源,你想看的小说通过强大搜索引擎一键搜索即可,主要的是阅读小说还能够获取红包现金奖励哦。
下载
奇热漫画app安卓版25.5M13451人在玩奇热漫画是一款非常不错的漫画阅读软件,具有很多强大的阅读功能,奇热漫画app实时为你更新全网最新最热的动漫资源。平台拥有海量精彩漫画,官方正版漫画
下载
奇热小说app24.8M234499人在玩安卓奇热小说app是专为众多爱看小说的人士提供的手机看小说的软件,省流量极速免费看小说,海量热门小说任你看,喜欢小说的小伙伴不要错过,赶快下载奇热小说网手机版客户端体验吧
下载
2022快看漫画App最新版69.0M51448人在玩2022快看漫画,相信许多玩微博的小伙伴们都已经知道这款APP了。吵架归吵架,至于这款快看漫画App到底做得怎么样,只有试过才知道!
下载
豆瓣阅读客户端app70.2M9579人在玩豆瓣阅读app是一款为豆瓣的用户们量身定做的APP,在豆瓣阅读这里你可以看到更加符合豆瓣用户喜好的各类文字作品,而且目前书籍依然在持续增长中。
下载
追书神器官方版70.1M19679人在玩追书神器2022最新版是一款超级强力的小说导读助手,目前几大热门的小说连载网站均有关联,你可以通过它方便地寻找自己喜欢的书籍。
下载
腾讯动漫71.9M13609人在玩腾讯动漫寒假档,许多大人们认为动漫就是小孩子看的东西,但是大概从80后开始,动漫就成为了许多人生活中的一部分,如果你喜欢看动漫,可以来腾讯动漫吧,这里有最新动漫更新视频
下载
书旗小说免费版本32.7M22553人在玩书旗小说免费版下载安装,书旗小说免费版本是一款以书旗网海量小说为基础的在线/离线阅读器,集合在线阅读、本地阅读、书包下载、自动书签、智能搜索、阅读设置等多项人性化功能。
下载
搜狗阅读器app19.5M6809人在玩搜狗阅读是搜狗公司依托于搜狗搜索的丰富资源,为安卓用户打造的移动阅读应用产品。搜狗阅读海量图书即搜即看,新闻大事掌握在手,更有离线缓存、精品推荐、更新提醒等功能,让您随时随地享受阅读的快乐。
下载
起点读书app新版本202237.2M11875人在玩起点读书app新版本,又名起点看书,是起点中文网推出的一款阅读软件。它支持本地阅读并提供起点在线书库,具备多种格式的解析阅读功能
下载