Created
June 6, 2025 02:22
-
-
Save thuykaka/d3df57f14042a7d5786047f3e976841d to your computer and use it in GitHub Desktop.
Crawl meta ad library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var session_id = self.crypto.randomUUID(); | |
| var lsd = require("LSD").token; | |
| var dtsg = require("DTSGInitialData").token; | |
| var uid = require("CurrentUserInitialData").USER_ID; | |
| var params = { | |
| "q":"loose weight", | |
| "countries[0]":"US", | |
| "count":30, | |
| "session_id":session_id, | |
| "active_status":"all", | |
| "ad_type":"all", | |
| "media_type":"all", | |
| "search_type":"keyword_unordered" | |
| }; | |
| var qs = new URLSearchParams(params).toString(); | |
| var url = `https://www.facebook.com/ads/library/async/search_ads/?${qs}`; | |
| var f = await fetch(url, { | |
| "credentials": "include", | |
| "headers": { | |
| "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 YellowWeb", | |
| "Accept": "*/*", | |
| "Accept-Language": "vi-VN;q=0.7,en;q=0.3", | |
| "Content-Type": "application/x-www-form-urlencoded", | |
| "X-FB-LSD": lsd, | |
| "Sec-Fetch-Dest": "empty", | |
| "Sec-Fetch-Mode": "cors", | |
| "Sec-Fetch-Site": "same-origin", | |
| }, | |
| "body": `__user=${uid}&__a=1&fb_dtsg=${dtsg}&lsd=${lsd}`, | |
| "method": "POST", | |
| "mode": "cors" | |
| }); | |
| var resp = await f.text(); | |
| console.log(resp); |
Author
oh, thanks guy. i will try it
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@hashcott bạn xem đỡ file này của mình nhé, cơ bản lúc ban đầu nó sẽ gọi với docId khác và parse kiểu khác, lúc sau nó sẽ gọi docId mới kèm cursor: