-
Notifications
You must be signed in to change notification settings - Fork 0
/
findWeibo.py
57 lines (47 loc) · 1.72 KB
/
findWeibo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from bs4 import BeautifulSoup
import requests,json
from comment import Comm
import os
url = 'http://m.weibo.cn/container/getIndex?type=uid&value=1191262305&containerid=1076031191262305&page=1'
wb_data = requests.get(url)
aa = str(wb_data.content, encoding = "utf-8")
bb = json.loads(aa)
theWeiBos = bb['cards']
NewWeiBo = theWeiBos[0]
NewWeiBo_itemid = NewWeiBo['itemid']
NewWeiBo_scheme = NewWeiBo['scheme']
NewWeiBo_mblog = NewWeiBo['mblog']
old = '0.1'
class
def diff(new):
global old
if new == old:
# 不继续下面操作
print('meiyou old:{}'.format(old))
else:
# 继续下面操作,
# 把NewWeiBo_scheme传到另外一个py文件,再评价,
NewUrl()
# 并给自己发送邮件
if NewWeiBo_mblog_retweeted:
# 转发的
# 把mailHtml_retweeted传到另外一个py文件,发送邮件
mailHtmlRetweeted()
else:
# 自己的
# 把mailHtml_own传到另外一个py文件,发送邮件
mailHtmlOwn()
old = new
print('gengxin old:{}'.format(old))
NewWeiBo_mblog_text = NewWeiBo_mblog['text']
NewWeiBo_mblog_user = NewWeiBo_mblog['user']
NewWeiBo_mblog_comments = NewWeiBo_mblog['comments_count']
# NewWeiBo_mblog_pics = NewWeiBo_mblog['pics']
NewWeiBo_mblog_retweeted = NewWeiBo_mblog['retweeted_status']
screen_name = NewWeiBo_mblog_user['screen_name']
profile_image_url = NewWeiBo_mblog_user['profile_image_url']
retweeted_text = NewWeiBo_mblog_retweeted['text']
retweeted_pics = NewWeiBo_mblog_retweeted['pics']
retweeted_pics_list = [x['large']['url'] for x in retweeted_pics]
retweeted_user = NewWeiBo_mblog_retweeted['user']
retweeted_user_name = retweeted_user['screen_name']