Scrapping Da Ma Cai 4D Results

Search for a command to run...

No comments yet. Be the first to comment.
Most AI agents that support scheduled tasks have two sources of instruction when a cron job fires: The cron prompt — the task-specific instructions you wrote when scheduling the job The skill — a re

TL;DR Scarp draw result, host on GitHub, retrieve it like API at damacai.hongineer.com. Data Scraping I have previously shared a technique for scraping Da Ma Cai draw result. Now I finally have time t

This is a Bash script that check if the replica (slave) health status. If there is an issue, it will exist with non-zero status. This is useful when used with monitoring tools like [Monit](https://mmo

chmod is a command-line utility used to change the access permissions of file system objects such as files and directories. It allows you to control who can read, write, and execute those objects. Changing Permissions Using Octal Notation Example Usa...
chown changes the ownership of files and directories. This involves modifying the user and/or group associated with a file, determining who has access and permissions. Changing File Ownership to a Specific User Example Usage: chown user file.txt What...
Tips for scrapping drawing results from Da Ma Cai (a lottery in Malaysia) website. This method works as of 7 July 2024. This is an undocumented method and not officially supported, so it might not work in future.
The information provided in this article is for educational purposes only. Web scraping practices and legalities can vary depending on the website and your location. It is your responsibility to ensure you have the necessary permissions before scraping data from any website. Scraping data without permission may violate the website's terms of service or even local laws.
Draws are conducted every Wednesday, Saturday and Sunday at 7 PM, and some Tuesdays. So it is not always consistent. If you need to get draw results for different days, you need to know what are the draw dates.
Send a GET request to https://www.damacai.com.my/ListPastResult. It returns a JSON object with a single drawdate attribute. The value is a string containing recent draw dates separated by space. The dates are in "YYYYMMDD" format.
This is a bad design. They could have used an array instead of string. Take note of the trailing space in this string. I recommend ISO 8601 date format for APIs.
Example request
curl 'https://www.damacai.com.my/ListPastResult'
To get the draw results, you must first retrieve an URL link (for a selected date). This link will direct you to the draw results.
Send a GET request to https://www.damacai.com.my/callpassresult?pastdate=<YYMMDD>. Replace "<YYMMDD>" with a draw date. You must include a HTTP header cookiesession: 363.
Example request
curl -H 'cookiesession: 363' 'https://www.damacai.com.my/callpassresult?pastdate=20240707'
Example result
{"link":"https://prddmcremt1.blob.core.windows.net/drawresult/DrawDate/20240707.json?sv=2014-02-14&sr=b&sig=gErL79ZbcEIDQ%2FlAmq6ZT1fOR%2FQqRWVk%2BslMtR0NXGE%3D&st=2024-07-07T15:10:38Z&se=2024-07-07T16:20:38Z&sp=r"}
It seems to be signed and valid for 1 hour.
Send a GET request to the link URL. The response is draw results in JSON format. There is a number of spelling errors. "Past" is sometime spelt as "pass", "consolation" is sometime spelt as "consolidate". The misspelled words and inconsistent naming convention triggers my OCD 🤢.
Example request
curl 'https://prddmcremt1.blob.core.windows.net/drawresult/DrawDate/20240707.json?sv=2014-02-14&sr=b&sig=vRNxKXftDFgWH1fWnQOoaVliFAIE0MffQ6m5B%2FysBVU%3D&st=2024-07-07T15%3A14%3A19Z&se=2024-07-07T16%3A24%3A19Z&sp=r'
MAY THE SOURCE BE WITH YOU