Porn Data Anaylize — 上传者 分类信息分析(github)

'''
视频作者 视频分类信息分析
http://www.h4ck.org.cn
by obaby
obaby@mars
email:root@obaby.org.cn
date: 2020.09.04
'''
from pyspark.sql.functions import col
import altair as alt
import pandas as pd
from matplotlib import pyplot as plt
%matplotlib inline
csv = spark.read.option("header",True).csv("hdfs://localhost:9000/data2/porn_data_movie.csv")
csv.printSchema()
root
 |-- id: string (nullable = true)
 |-- create: string (nullable = true)
 |-- update: string (nullable = true)
 |-- name: string (nullable = true)
 |-- describe: string (nullable = true)
 |-- source_id: string (nullable = true)
 |-- publish_time: string (nullable = true)
 |-- play_count: string (nullable = true)
 |-- good_count: string (nullable = true)
 |-- bad_count: string (nullable = true)
 |-- link_count: string (nullable = true)
 |-- comment_count: string (nullable = true)
 |-- designation: string (nullable = true)
 |-- category_id: string (nullable = true)
 |-- porn_site_id: string (nullable = true)
 |-- uploader_id: string (nullable = true)
 |-- producer: string (nullable = true)
csv.select('name', 'describe', 'uploader_id').show()
Continue Reading

Porn Data Anaylize — 标签 模特信息分析(github)

from pyspark.sql.functions import col
import altair as alt

import pandas as pd
from matplotlib import pyplot as plt
get_ipython().run_line_magic('matplotlib', 'inline')
csv = spark.read.option("header",True).csv("hdfs://localhost:9000/data2/porn_data_movie_tags.csv")
tag_csv = spark.read.option("header",True).csv("hdfs://localhost:9000/data2/porn_data_tag.csv")
csv.show()

+---+--------+------+
| id|movie_id|tag_id|
+---+--------+------+
|  1|    9909|     1|
|  2|    9909|     2|
|  3|    9909|     3|
|  4|    9909|     4|
|  5|    9910|     5|
|  6|    9910|     6|
|  7|    9910|     7|
|  8|    9910|     8|
|  9|    9910|     9|
| 10|    9910|    10|
| 11|    9911|    12|
| 12|    9911|     2|
| 13|    9911|     1|
| 14|    9911|    13|
| 15|    9910|    11|
| 16|    9911|    14|
| 17|    9911|    15|
| 18|    9911|     5|
| 19|    9910|    16|
| 20|    9910|    17|
+---+--------+------+
only showing top 20 rows

Continue Reading

Porn Data Anaylize — Spark安装

spark默认使用的Python版本为2,可以修改.bashrc文件让spark默认使用python3。修改.bashrc增加如下行:

# anaconda
export ANACONDA_HOME=/home/dbuser/anaconda3/
export PATH=$ANACONDA_HOME:$PATH
# spark
export PYSPARK_PYTHON=/home/dbuser/anaconda3/bin/python3

然后重新启动pyspark就是3了,anaconda下的python文件版本也是2。

Continue Reading

Porn Data Anaylize — Hadoop安装

这是一个系列的数据分析相关项目,包括环境搭建,数据分析,分析代码,分析报告等。目前数据来源于爬取到的100,000+数据
文章主要介绍相关的方法和原理,也算是自己对于大数据的一个初步的认识。

代码不会涉及具体的数据信息。如果需要相关的数据,可以参考以下文章自己爬取相关的数据信息:

某加密到牙齿的APP数据加密分析
攻城略地 再下一Porn

安装参考的是《Python + Spark 2.0+Hadoop机器学习与大数据实战》(林大贵 著),首先吐槽一下,林大贵的几本书前几章的内容完全一样,尤其是上面提到的这本与《Hadoop + Spark大数据巨量分析与机器学习实战》,两本书前7章内容完全一致。
买了两本书其实相当于买了一本半,并且重复的都是非常基础的部分。对于整本书来说倒是降低了写作的难度和时间,并且两本书的实例也基本一致,不过使用的语言略有不同。
书上介绍的安装版本比较老旧,也没有必要去安装一个老旧的版本。所以这里我安装的是3.3.0 具体的安装流程可以参考这个链接:http://hadoopspark.blogspot.com/2015/09/4-hadoop-26-single-node-cluster.html

不过需要注意的是里面的几条命令可能稍微有些问题: 使用下面的这条命令生成的key文件对应的host是本机的主机名:

ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa

如果系统没有设置hostname,可以使用下面的命令生成key:

ssh localhost ssh-keygen -t rsa

两者的区别在于第一条命令生成的是username@hostname,第二条名称生成的是username@localhost

Continue Reading

ModuleNotFoundError: No module named ‘cryptography.hazmat.bindings._padding’

ubuntu下执行命令出现如下错误:

ubuntu@ip-172-31-11-253:~/nineuu_spider/Maomi$ python3 maomi.py
Traceback (most recent call last):
  File "maomi.py", line 8, in 
    from cryptography.hazmat.primitives import padding
  File "/usr/lib/python3/dist-packages/cryptography/hazmat/primitives/padding.py", line 13, in 
    from cryptography.hazmat.bindings._padding import lib
ModuleNotFoundError: No module named 'cryptography.hazmat.bindings._padding'

但是实际上cryptography模块已经安装了:

如果要解决这个错误,安装paramiko即可:

pip3 install paramiko
Continue Reading

微信公众号文章爬虫

github上关于微信公众号文章的爬虫还是蛮多的,一搜一大把。基于各种技术,这里分享的是之前的做的基于selenium实现的方法。

要爬取的公众号列表修改wx_account.py下的内容

微信公众平台账号登录修改baby_wx_post_spider.py下的如下代码:

   
username='root@obaby.org.cn'# 账号
password='********'# 密码

如果要存储数据修改如下代码:

    
# add_wx_post(post_title, post_date, content, html_content, pcs, images_link_text, post_url, "2"
#             wx_account, nickname, wx_intro)
print('在此处更新数据库')

登录方式说明:如果不指定账号密码可以直接扫码登录,但是扫码之后需要输入密码,反而更麻烦。

输出日志:

H:\PyCharmProjects\baby_wx_spider\venv\Scripts\python.exe H:/PyCharmProjects/baby_wx_spider/baby_wx_post_spider.py
****************************************************************************************************
Wechat Post Spider System
By:obaby
http://www.h4ck.org.cn
http://www.obaby.org.cn
http://www.findu.co
****************************************************************************************************
[*] System starting ..................
[*] Try to login with username:obaby.lh@163.com Password: ***************
[*] Please scan the qrcode to continue
[*] Scan the QRCode with your cell phone to login!!
[*] Spider starting.....................
[*] Current Wechat account is:
青岛文旅
[*] all passed!
[*] Link:http://mp.weixin.qq.com/s?__biz=MzU0NTc4OTI5MQ==&mid=2247490126&idx=1&sn=29a88b4ceef1cdbd6584702fdd46112a&chksm=fb66de4acc11575c946e802cb475845d7ff540d5a0d6da23834c0c4caa27bd3c3b7c2dd762e6#rd
在此处更新数据库
[*] Link:http://mp.weixin.qq.com/s?__biz=MzU0NTc4OTI5MQ==&mid=2247490126&idx=2&sn=87724f394f1533a23f50e5fddf7c88c1&chksm=fb66de4acc11575cb5c3a610371936a14f2743916b332f0bea3a3edc63dc2648351b386a0b95#rd
在此处更新数据库
[*] Link:http://mp.weixin.qq.com/s?__biz=MzU0NTc4OTI5MQ==&mid=2247490126&idx=3&sn=a9a3992058f069149102ea0fd9dae0b4&chksm=fb66de4acc11575c2c0ef3afe8c5de6c2e8b432c1b3d6c3e8d69f5cb439a85962517b147ee8b#rd
在此处更新数据库

项目地址: https://github.com/obaby/baby_wx_post_spider

PS: 代码如果发现bug,请自行修改!由于微信后台一直变化,所以如果代码不能运行,重新定位相关的元素更新xpath即可

m3u8 下载工具 V20.6.01 [OSX]

功能与windows版本一致,使用之前需要安装ffmpeg,可以通过home brew 安装

 brew install ffmpeg

. 默认路径为/usr/local/bin/ffmpeg, 如果路径不是这个路径可以通过ls软连接或者-m 参数指定ffmpeg路径。

几个osx下打包遇到的坑:

  1. pyinstaller打包之后报错:FileNotFoundError: Tcl data directory ,我这里没有用到tcl相关的内容可以直接修改:env/lib/python3.7/site-packages/PyInstaller/loader/rthooks/pyi_rth_tkinter.py
    注释掉如下几行:

    #if not os.path.isdir(tcldir):
    #raise FileNotFoundError('Tcl data directory "%s" not found.' % (tcldir))
    #if not os.path.isdir(tkdir):
    #raise FileNotFoundError('Tk data directory "%s" not found.' % (tkdir))
  2. pyinstaller osx 和windows下的add-data参数的分割符不一样,windows平台为分号; osx为冒号:
Continue Reading