Web Scraping Use Tampermonkey
QuickSilver.web.id – Web Scraping Using UserScipt on Tampermonkey
Tampermonkey. For those of you who want to know what Tampermonkey is, you can visit this page for more details.
Tampermonkey really helps me in experimenting, the benefits of this extension can give me quite satisfactory results.
One example of the benefits of using Tampermonkey for is scraping an API code to get some data on a website.
In this post I want to share my experience of scraping the web with userscript on tampermonkey
As per the title above, web scraping using tampermonkey.
In this post I want to share my experience of scraping the web with userscript on tampermonkey
As per the title above, web scraping using tampermonkey
You need to underline, the use of userscipt on tampermonkey is macth with the website itself, where if it is added to your script, then tampermonkey will not work.
Example:
//@match https://shopee.co.id/*
For the example above, it only applies to the Home page, and does not apply to any other page.
How do I make it apply on all pages?
Use the following code sample:
//@match *://shopee.co.id/*
Continue to the discussion.
Here we take an example of scraping a data on the Shopee website.
To scrape data on a web page, you must know an API on the website.
On the shopee website, Shopee itself provides a URL API that we can use to display the data we need.
For example, in the Shopee Flash Sale program, we want to know the description information of the Flash Sale program.
Here is the API url for the description of the Flash Sale Program on the Shopee Website
https://shopee.co.id/api/v4/flash_sale/get_all_sessions
Well. How and how does it erode the web using userscript in tampermonkey?
Fisrt :
- Open Chrome Browser
- Then you open the Shopee website
- And click Tampermonkey Extension, then select Create a new script…, as shown below:

On the Tampermonkey editor page, you can paste the following code:
// ==UserScript==
// @name Get Deskription Flash Sale Shopee
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Flash Sale Deskription
// @author tdee.gits
// @match *://shopee.co.id/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=co.id
// @grant none
// ==/UserScript==
(function() {
'use strict';
function getDeskription_flash_sale(){
// Call the API
fetch("https://shopee.co.id/api/v4/flash_sale/get_all_sessions", {
"headers": {
"accept": "*/*",
"accept-language": "en-US,en;q=0.9,id-ID;q=0.8,id;q=0.7",
"sec-ch-ua": "\"Chromium\";v=\"112\", \"Google Chrome\";v=\"112\", \"Not:A-Brand\";v=\"99\"",
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": "\"Windows\"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"x-api-source": "pc",
"x-requested-with": "XMLHttpRequest",
"x-shopee-language": "id"
},
"referrer": "https://shopee.co.id/flash_sale",
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
}).then(function (response) {
if (response.ok) {
return response.json();
} else {
return Promise.reject(response);
}
}).then(function (data) {
let sesi = data.data.sessions;
for (var s = 0; s < sesi.length; s++) {
var session = Object.keys(sesi)[s];
if (session) {
console.log(sesi[session].description)
}
}
})
}
// function
getDeskription_flash_sale();
})();
- Then click File and select Save
- Back to Shopee website Tab
- Press F12 on your keyboard to open Developer Tools, then select Console Tab.
- Refresh the Shopee page, then you will get a description data about the description of the Shopee Flas Sale Program, as shown below

I think for the explanation is enough to get here, please develop it.
Good luck, hopefully useful.
Single-stream greetings
QuickSilver
