Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
24b0ddf666 |
@@ -77,7 +77,8 @@ Bypass Cloudflare protection and get cookies/tokens.
|
|||||||
"mode": "iuam",
|
"mode": "iuam",
|
||||||
"domain": "https://olamovies.watch/generate",
|
"domain": "https://olamovies.watch/generate",
|
||||||
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||||
"include_html": true
|
"include_html": true,
|
||||||
|
"include_cookies": true
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -86,6 +87,7 @@ Bypass Cloudflare protection and get cookies/tokens.
|
|||||||
- **`domain`** (required): Target website URL
|
- **`domain`** (required): Target website URL
|
||||||
- **`user_agent`** (optional): User-Agent to use for the browser session
|
- **`user_agent`** (optional): User-Agent to use for the browser session
|
||||||
- **`include_html`** (optional): `true` to include the final page HTML in IUAM responses
|
- **`include_html`** (optional): `true` to include the final page HTML in IUAM responses
|
||||||
|
- **`include_cookies`** (optional): `true` to include all cookies in IUAM responses
|
||||||
- **`proxy`** (optional): Proxy configuration object
|
- **`proxy`** (optional): Proxy configuration object
|
||||||
|
|
||||||
#### Response (Success)
|
#### Response (Success)
|
||||||
@@ -94,7 +96,10 @@ Bypass Cloudflare protection and get cookies/tokens.
|
|||||||
"cf_clearance": "eNm9UOgqoNDTP.fmAK9JfvirEmLVpmd.ZWIfdqQxuTc-1758610092-1.2-2NwZwW6nK23HrAH71MtvOek9vCiiS7pUBGIPtra_gSBxYxY2csa6hW0j7i...",
|
"cf_clearance": "eNm9UOgqoNDTP.fmAK9JfvirEmLVpmd.ZWIfdqQxuTc-1758610092-1.2-2NwZwW6nK23HrAH71MtvOek9vCiiS7pUBGIPtra_gSBxYxY2csa6hW0j7i...",
|
||||||
"user_agent": "Mozilla/5.0...",
|
"user_agent": "Mozilla/5.0...",
|
||||||
"elapsed_time": 3.05,
|
"elapsed_time": 3.05,
|
||||||
"html": "<!DOCTYPE html><html>...</html>"
|
"html": "<!DOCTYPE html><html>...</html>",
|
||||||
|
"cookies": [
|
||||||
|
{ "name": "cf_clearance", "value": "...", "domain": ".example.com" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
async function getPageHtml(page, url) {
|
async function ensurePageLoaded(page, url) {
|
||||||
try {
|
try {
|
||||||
await page.goto(url, { waitUntil: "domcontentloaded", timeout: 10000 })
|
await page.goto(url, { waitUntil: "domcontentloaded", timeout: 10000 })
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getPageHtml(page) {
|
||||||
try {
|
try {
|
||||||
return await page.content()
|
return await page.content()
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
@@ -10,6 +12,14 @@ async function getPageHtml(page, url) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getPageCookies(page, url) {
|
||||||
|
try {
|
||||||
|
return await page.cookies(url)
|
||||||
|
} catch (_) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function cloudflare(data, page) {
|
async function cloudflare(data, page) {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
if (!data.domain) return reject(new Error("Missing domain parameter"))
|
if (!data.domain) return reject(new Error("Missing domain parameter"))
|
||||||
@@ -28,6 +38,7 @@ async function cloudflare(data, page) {
|
|||||||
elapsed_time: elapsedTime,
|
elapsed_time: elapsedTime,
|
||||||
}
|
}
|
||||||
if (data.include_html) response.html = null
|
if (data.include_html) response.html = null
|
||||||
|
if (data.include_cookies) response.cookies = null
|
||||||
resolve(response)
|
resolve(response)
|
||||||
}
|
}
|
||||||
}, 20000)
|
}, 20000)
|
||||||
@@ -72,8 +83,16 @@ async function cloudflare(data, page) {
|
|||||||
elapsed_time: elapsedTime,
|
elapsed_time: elapsedTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.include_html || data.include_cookies) {
|
||||||
|
await ensurePageLoaded(page, data.domain)
|
||||||
|
}
|
||||||
|
|
||||||
if (data.include_html) {
|
if (data.include_html) {
|
||||||
response.html = await getPageHtml(page, data.domain)
|
response.html = await getPageHtml(page)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.include_cookies) {
|
||||||
|
response.cookies = await getPageCookies(page, data.domain)
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve(response)
|
resolve(response)
|
||||||
|
|||||||
7
index.js
7
index.js
@@ -106,6 +106,9 @@ app.post('/cloudflare', async (req, res) => {
|
|||||||
if (typeof data.include_html !== 'undefined' && typeof data.include_html !== 'boolean') {
|
if (typeof data.include_html !== 'undefined' && typeof data.include_html !== 'boolean') {
|
||||||
return res.status(400).json({ message: 'Bad Request: invalid include_html' })
|
return res.status(400).json({ message: 'Bad Request: invalid include_html' })
|
||||||
}
|
}
|
||||||
|
if (typeof data.include_cookies !== 'undefined' && typeof data.include_cookies !== 'boolean') {
|
||||||
|
return res.status(400).json({ message: 'Bad Request: invalid include_cookies' })
|
||||||
|
}
|
||||||
if (authToken && data.authToken !== authToken) {
|
if (authToken && data.authToken !== authToken) {
|
||||||
return res.status(401).json({ message: 'Unauthorized' })
|
return res.status(401).json({ message: 'Unauthorized' })
|
||||||
}
|
}
|
||||||
@@ -115,7 +118,7 @@ app.post('/cloudflare', async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let cacheKey, cached
|
let cacheKey, cached
|
||||||
if (CACHE_ENABLED && data.mode === "iuam" && !data.include_html) {
|
if (CACHE_ENABLED && data.mode === "iuam" && !data.include_html && !data.include_cookies) {
|
||||||
|
|
||||||
cacheKey = JSON.stringify(data)
|
cacheKey = JSON.stringify(data)
|
||||||
cached = readCache(cacheKey)
|
cached = readCache(cacheKey)
|
||||||
@@ -153,7 +156,7 @@ app.post('/cloudflare', async (req, res) => {
|
|||||||
.then(r => ({ ...r }))
|
.then(r => ({ ...r }))
|
||||||
.catch(err => ({ code: 500, message: err.message }))
|
.catch(err => ({ code: 500, message: err.message }))
|
||||||
|
|
||||||
if (CACHE_ENABLED && !data.include_html && (!result.code || result.code === 200)) {
|
if (CACHE_ENABLED && !data.include_html && !data.include_cookies && (!result.code || result.code === 200)) {
|
||||||
writeCache(cacheKey, result)
|
writeCache(cacheKey, result)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user