This article is participating in Python Theme Month. See the link to the event for more details
Today to introduce something different ~ ha ha 😝
The diagram below ~
What do you think of when you see this picture
In fact, I was just bored, I found a place to practice crawler haha, and then the data visualization operation, there is such a 3D chart
And still have a little harvest, let me introduce briefly below first!
A crawling target
As shown in the figure, the target of this climb is the back-end leaderboard, yes, this is the data, and then the author corresponding likes, ratings, visualization operation
API access
Then, press F12 in the browser to find the corresponding API from the console
Import this package from Hyper. Contrib import HTTP20Adapter. Import this package from Hyper
Http2.0
Http2.0 has several new features:
- New binary format
- MultiPlexing
- The header compression
- Server push
How header compression works in Http2.0 :(image shared by Google’s tech guru)
In simple terms, both the client and the server maintain a static table, and when transferring information, they can directly pass the index corresponding to the header to each other. Instead of transferring header: GET, they can reduce the transfer size
With the APi, we just clean the data we get
pyecharts
After cleaning the data, we need to visualize the data
In fact, pyecharts encapsulates the Echarts chart library, which is similar to V-Charts encapsulated by Vue. If you don’t understand many parameters, you have to go to the echarts official document to check, or you can debug it online at 😄
👉 Pyecharts official document: pyecharts.org/#/zh-cn/int…
👉 echarts official documentation: echarts.apache.org/examples/zh…
Really nice 😄
code
Code in the official website, directly copy the above demo, a simple transformation can be
Code is relatively simple, here is a simple core steps 😄, and finally the data will be filled in the corresponding position of the demo above can be
# Fill data to get maximum likes
def parse_user_and_got_max_count(users, userNames, b3d_data) :
max_digg_count = 0
for user in users:
user_name = dict(user).get('user_name')
userNames.append(user_name)
user_index = len(userNames) - 1
got_digg_count = dict(user).get('got_digg_count')
# got_view_count = dict(user).get('got_view_count')
level = dict(user).get('level')
b3d_data.append([level - 1, user_index, got_digg_count])
if got_digg_count > max_digg_count:
max_digg_count = got_digg_count
return max_digg_count
Copy the code
The result is as follows. Open the generated HTML page.
The effect
Finally, let’s take a look at this effect
The last
Well, I’m off to the world of despair. (I didn’t expect that one day I, too, would have to worry about the world “s sole remaining.)