当前位置:网站首页>Is it too troublesome to turn pages manually when you encounter a form? I'll teach you to write a script that shows all the data on one page
Is it too troublesome to turn pages manually when you encounter a form? I'll teach you to write a script that shows all the data on one page
2022-06-11 22:37:00 【Data ape vision】
The confusion of Internet users
People who read this article , It must be all Internet users . You must have met 「 form 」.
When we read the tables , There may be this confusion :
- The form does not support keyword search
- The table does not support sorting by a column
- Each page of the form can only show 10 Data , Need to keep turning pages , To see all the content
What shall I do? ?
If only one page of the table could show all the data !
In this case :
- Keyword search can be done through the browser 「 Search for 」 Function realization (
Ctrl+ForCommand+F). - Sorting can be realized by referring to my next article ( Coming soon ).
- There is no need to turn pages manually .
Next , Let me HullQin To provide you with a solution , Let the table show all the data on one page !
Solution
Take nuggets for example
We found that , This is called list_by_user Of API, Is the back-end paging API.
We just need to iterate through the request , You can get all the data in the form , Then let the front end be displayed at one time ~
Here you are 2 Two problems need to be solved :
- I'm going to cycle through the interface by page , So as to obtain all the data of the table .
- I want to make the front-end Nuggets code request when , Only request 1 Time , Get all the data . In this way, it can be displayed at one time .
Solve the 1 A question : Get all the data
Let's open the browser's developer tools , open Network( The Internet ) panel , Found this called list_by_user Of API, The required data of the table is returned .
We need to modify it page_no Parameters , Then iterate over it many times , Always request this interface , Until the last page .
Chrome The most convenient thing is , Can directly Copy as fetch, After clicking , You can copy the request fetch edition , do 「 Replay attack 」 It's too convenient ,Chrome The intimate function of is really too painful !


Of course, the above 「 Replay attack 」 Use quotation marks , It's not really a replay attack , We just did one more query , It does not change the data state of the back end .
below , Change it fetch function , We need to save its results .
This API The return result of is :

Our ultimate goal is , hold data All the data in are integrated into the same array .
const result = [];
const res = await fetch('... What you copied ');
const data = await res.json();
result.push(...data.data);
Copy code 
Next , We add... To the above logic for Loop to achieve paging access :
const result = [];
// Don't put too much pressure on Nuggets , We define a sleep function ,1 Just ask once per second
const sleep = async () => new Promise(resolve => setTimeout(resolve, 1000));
for (let i = 1; i <= 2; i++) { // Note that you need to i The maximum value of is changed to , See how many times you need to download all the data .
const res = await fetch("https://api.juejin.cn/content_api/v1/article/list_by_user? Change it to your parameter !", {
"headers": { "content-type": "application/json" },
"body": "{\"page_size\":10,\"page_no\":" + i + ",\"audit_status\":null}",
"method": "POST",
"mode": "cors",
"credentials": "include",
});
const data = await res.json();
result.push(...data.data);
await sleep(); // Don't put too much pressure on Nuggets , We 1 Just ask once per second
}
Copy code 
Now? ,result That's all the data in our table !
边栏推荐
- Meetup回顾|DevOps&MLOps如何在企业中解决机器学习困境?
- JsonParseException: Unrecognized token ‘username‘: was expecting表单提交登陆数据报错
- Lecture de l'article dense Visual SLAM for RGB - D Cameras
- [Yu Yue education] Yancheng Normal University Advanced Algebra reference
- Regular execution of shell scripts in crontab
- 2022新兴市场品牌出海线上峰会即将举办 ADVANCE.AI CEO寿栋将受邀出席
- 【Uniapp 原生插件】商米钱箱插件
- Tkinter学习笔记(三)
- Leetcode stack topic summary
- The device is in use when win10 ejects USB
猜你喜欢

电脑强制关机 oracle登录不上

一款开源的Markdown转富文本编辑器的实现原理剖析

想做钢铁侠?听说很多大佬都是用它入门的

If I take the college entrance examination again, I will study mathematics well!

Regular execution of shell scripts in crontab

The device is in use when win10 ejects USB
Gcache of goframe memory cache

Tkinter学习笔记(四)

动态规划之0-1背包问题(详解+分析+原码)

华为设备配置HoVPN
随机推荐
移动端——swipe特效之图片时间轴
Solution to page locking caused by xshell accidentally pressing ctrl+s
PHP+MYSQL图书管理系统(课设)
Basic operation and question type summary of linked list
Php+mysql library management system (course design)
Learn to crawl for a month and earn 6000 a month? Don't be fooled. The teacher told you the truth about the reptile
Unity中使用调用Shell的命令行
完好性简要介绍
Introduction to MySQL transactions
习题11-2 查找星期 (15 分)
Only three steps are needed to learn how to use low code thingjs to connect with Sen data Dix data
NLP - fastText
Exercise 11-2 find week (15 points)
[uniapp native plug-in] shangmi cashbox plug-in
批改网高分短语&句型
IEEE-754 浮点转换器
Matlab point cloud processing (XXV): point cloud generation DEM (pc2dem)
Analysis of the implementation principle of an open source markdown to rich text editor
二叉树的基本操作与题型总结
Exercise 8-2 finding a specified element in an array (15 points)