Python中写(抄)了几个小工具, V 友看看?
地址https://github.com/tonyxyl/tools
这个脚本是用字典跑网站路由的, 目的是发现一些曾经爆出过漏洞的隐藏链接, 比如后台登陆入口, 备份的配置文件等;
这个脚本运行后, 可以在浏览器页面上运行 python 代码片段;
这个脚本是用 tkinter 模块写的简易邮件发送客户端;
预约一个 windows 定时关机任务, 取消定时关机任务
douban_comment.ipynb
抓取豆瓣电影短评, 结巴分词, 生成词云
另:以后有想法会一直更新。
Python中写(抄)了几个小工具, V 友看看?
收藏一下
我无法理解你的问题。
简单,好玩。
web_runtime.py 只能用 localhost 打开,127.0.0.1,你就返回错误了。其他的在看
star 了,看看
词云那个应该不能用了吧,豆瓣电影现在登陆之后最多返回 500 条短篇。
能用的,在 mac 和 win 上都测试过。至于能返回多少页,不登录状态下容易被反爬,登陆后没有完全爬完所有页,单线程递归爬取太慢,但手工点击是可以翻完所有页的。
#6 你现在试试?我前段时间发现的,然后刚刚回复你之前还去试过,当 start=480 的时候就没有下一页可点了,已登录。
mark,多谢分享
mark 一个,有空看看
豆瓣那个, 报错 OSError: cannot open resource
请问这是什么意思?
要在 jupyter notebook 上跑的
我的确是在 jupyter notebook 上跑得,然后出现了这个问题。。
新手小白看不懂报错。。
OSError Traceback (most recent call last)
<ipython-input-2-8e2fa2e30a58> in <module>()
101 comment_url = urljoin(url, ‘comments?start=0&limit=20&sort=new_score&status=P&percent_type=’)
102 parse_comment(comment_url, headers)
–> 103 generate_cloud()
<ipython-input-2-8e2fa2e30a58> in generate_cloud()
72 word_frequence = {x[0]:x[1] for x in words_stat.head(1000).values}
73
—> 74 wordcloud = wordcloud.fit_words(word_frequence)
75 plt.imshow(wordcloud)
76
/usr/local/lib/python3.6/site-packages/wordcloud/wordcloud.py in fit_words(self, frequencies)
329 self
330 “”"
–> 331 return self.generate_from_frequencies(frequencies)
332
333 def generate_from_frequencies(self, frequencies, max_font_size=None):
/usr/local/lib/python3.6/site-packages/wordcloud/wordcloud.py in generate_from_frequencies(self, frequencies, max_font_size)
430 while True:
431 # try to find a position
–> 432 font = ImageFont.truetype(self.font_path, font_size)
433 # transpose font optionally
434 transposed_font = ImageFont.TransposedFont(
/usr/local/lib/python3.6/site-packages/PIL/ImageFont.py in truetype(font, size, index, encoding, layout_engine)
258
259 try:
–> 260 return FreeTypeFont(font, size, index, encoding, layout_engine)
261 except IOError:
262 ttf_filename = os.path.basename(font)
/usr/local/lib/python3.6/site-packages/PIL/ImageFont.py in init(self, font, size, index, encoding, layout_engine)
141
142 if isPath(font):
–> 143 self.font = core.getfont(font, size, index, encoding, layout_engine=layout_engine)
144 else:
145 self.font_bytes = font.read()
OSError: cannot open resource
好了,已解决,是缺少了 simhei.ttf 字体导致的
新的问题出现,有些爬取正常,有些出错了。。
AttributeError Traceback (most recent call last)
<ipython-input-5-8e2fa2e30a58> in <module>()
100 print(’\n================================\n\n’)
101 comment_url = urljoin(url, ‘comments?start=0&limit=20&sort=new_score&status=P&percent_type=’)
–> 102 parse_comment(comment_url, headers)
103 generate_cloud()
<ipython-input-5-8e2fa2e30a58> in parse_comment(url, headers)
43 comment_divs = soup.find_all(‘div’, class_=‘comment’)
44 if comment_divs is not None:
—> 45 comments += ‘’.join([item.find(‘p’).string.strip() for item in comment_divs])
46 next_page = soup.find(‘a’, class_=‘next’)
47 if next_page is not None and page < 30:
<ipython-input-5-8e2fa2e30a58> in <listcomp>(.0)
43 comment_divs = soup.find_all(‘div’, class_=‘comment’)
44 if comment_divs is not None:
—> 45 comments += ‘’.join([item.find(‘p’).string.strip() for item in comment_divs])
46 next_page = soup.find(‘a’, class_=‘next’)
47 if next_page is not None and page < 30:
AttributeError: ‘NoneType’ object has no attribute 'strip’
麻烦看下这是什么错误
多谢反馈,已经修复,可以去看最新的代码。
好像。。还是有问题。。不知道是不是被反爬了,
还是之前的报错’NoneType’ object has no attribute ‘strip’。
我的测试网址: https://movie.douban.com/subject/26942674/
刚刚又改进了一点,测试了你给的链接,没问题了。
棒棒哒~

