Skip to content

Commit 372b0e3

Browse files
author
刘志军
committed
add xingqiu crawler
2 parents a809dec + cd401e6 commit 372b0e3

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

heart2/heart.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def fetch_data(uid=None, container_id=None):
4747
params['page'] = str(page)
4848
params['containerid'] = container_id
4949
res = requests.get(url, params=params, headers=headers)
50-
cards = res.json().get("cards")
50+
cards = res.json().get("data").get("cards")
5151

5252
for card in cards:
5353
# 每条微博的正文内容
@@ -63,7 +63,8 @@ def fetch_data(uid=None, container_id=None):
6363

6464
def grey_color_func(word, font_size, position, orientation, random_state=None,
6565
**kwargs):
66-
s = "hsl(0, 0%%, %d%%)" % 0
66+
s = "hsl(255, 0%%, %d%%)" % 0
67+
print(s)
6768
return s
6869

6970

@@ -84,10 +85,33 @@ def generate_image():
8485
plt.title(u"天下有情人终成眷属")
8586
plt.imshow(wordcloud.recolor(color_func=grey_color_func, random_state=3),
8687
interpolation="bilinear")
88+
# mask_img = imread('./logo.jpg', flatten=True)
89+
#
90+
# wordcloud = WordCloud(font_path='/Library/Fonts/Songti.ttc',
91+
# background_color="white",
92+
# max_words=80,
93+
# mask=mask_img
94+
# ).generate(data)
95+
# plt.figure(figsize=(9, 6))
96+
# plt.imshow(wordcloud.recolor(color_func=grey_color_func, random_state=3), interpolation="bilinear")
97+
98+
plt.imshow(wordcloud, interpolation="bilinear")
99+
# plt.axis("off")
100+
# plt.show()
101+
102+
103+
104+
# wordcloud = WordCloud(
105+
# font_path='/Library/Fonts/Songti.ttc',
106+
# background_color='white',
107+
# mask=mask_img
108+
# ).generate(data)
109+
# plt.imshow(wordcloud.recolor(color_func=grey_color_func, random_state=3),
110+
# interpolation="bilinear")
87111
plt.axis('off')
88112
plt.savefig('./heart3.jpg', dpi=1600)
89113

90114

91115
if __name__ == '__main__':
92-
fetch_data("1192515960", "1076031192515960")
116+
# fetch_data("1192515960", "1076031192515960")
93117
generate_image()

0 commit comments

Comments
 (0)