Spaces:
Build error
Build error
saas: tweaks
Browse files- src/api/crawler.ts +1 -10
- src/api/serp.ts +1 -1
- src/services/serp/google.ts +2 -8
- thinapps-shared +1 -1
src/api/crawler.ts
CHANGED
|
@@ -891,9 +891,6 @@ export class CrawlerHost extends RPCHost {
|
|
| 891 |
}
|
| 892 |
} else if (crawlOpts?.allocProxy && crawlOpts.allocProxy !== 'none' && !crawlOpts.proxyUrl) {
|
| 893 |
const proxyUrl = await this.proxyProvider.alloc(this.figureOutBestProxyCountry(crawlOpts));
|
| 894 |
-
if (proxyUrl.protocol === 'socks5h:') {
|
| 895 |
-
proxyUrl.protocol = 'socks5:';
|
| 896 |
-
}
|
| 897 |
crawlOpts.proxyUrl = proxyUrl.href;
|
| 898 |
}
|
| 899 |
|
|
@@ -1242,7 +1239,6 @@ export class CrawlerHost extends RPCHost {
|
|
| 1242 |
};
|
| 1243 |
}
|
| 1244 |
|
| 1245 |
-
retryDet = new WeakSet<ExtraScrappingOptions>();
|
| 1246 |
@retryWith((err) => {
|
| 1247 |
if (err instanceof ServiceBadApproachError) {
|
| 1248 |
return false;
|
|
@@ -1263,12 +1259,7 @@ export class CrawlerHost extends RPCHost {
|
|
| 1263 |
}
|
| 1264 |
|
| 1265 |
const proxy = await this.proxyProvider.alloc(this.figureOutBestProxyCountry(opts));
|
| 1266 |
-
|
| 1267 |
-
if (this.retryDet.has(opts) && proxy.protocol === 'socks5h:') {
|
| 1268 |
-
proxy.protocol = 'socks5:';
|
| 1269 |
-
}
|
| 1270 |
-
this.retryDet.add(opts);
|
| 1271 |
-
}
|
| 1272 |
const r = await this.curlControl.sideLoad(url, {
|
| 1273 |
...opts,
|
| 1274 |
proxyUrl: proxy.href,
|
|
|
|
| 891 |
}
|
| 892 |
} else if (crawlOpts?.allocProxy && crawlOpts.allocProxy !== 'none' && !crawlOpts.proxyUrl) {
|
| 893 |
const proxyUrl = await this.proxyProvider.alloc(this.figureOutBestProxyCountry(crawlOpts));
|
|
|
|
|
|
|
|
|
|
| 894 |
crawlOpts.proxyUrl = proxyUrl.href;
|
| 895 |
}
|
| 896 |
|
|
|
|
| 1239 |
};
|
| 1240 |
}
|
| 1241 |
|
|
|
|
| 1242 |
@retryWith((err) => {
|
| 1243 |
if (err instanceof ServiceBadApproachError) {
|
| 1244 |
return false;
|
|
|
|
| 1259 |
}
|
| 1260 |
|
| 1261 |
const proxy = await this.proxyProvider.alloc(this.figureOutBestProxyCountry(opts));
|
| 1262 |
+
this.logger.debug(`Proxy allocated`, { proxy: proxy.href });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1263 |
const r = await this.curlControl.sideLoad(url, {
|
| 1264 |
...opts,
|
| 1265 |
proxyUrl: proxy.href,
|
src/api/serp.ts
CHANGED
|
@@ -136,7 +136,7 @@ export class SerpHost extends RPCHost {
|
|
| 136 |
@Param('hl', { validate: (v: string) => WORLD_LANGUAGES.some(l => l.code === v) }) hl?: string,
|
| 137 |
@Param('location') location?: string,
|
| 138 |
@Param('page') page?: number,
|
| 139 |
-
@Param('fallback'
|
| 140 |
) {
|
| 141 |
const authToken = auth.bearerToken;
|
| 142 |
let highFreqKey: RateLimitCache | undefined;
|
|
|
|
| 136 |
@Param('hl', { validate: (v: string) => WORLD_LANGUAGES.some(l => l.code === v) }) hl?: string,
|
| 137 |
@Param('location') location?: string,
|
| 138 |
@Param('page') page?: number,
|
| 139 |
+
@Param('fallback') fallback?: boolean,
|
| 140 |
) {
|
| 141 |
const authToken = auth.bearerToken;
|
| 142 |
let highFreqKey: RateLimitCache | undefined;
|
src/services/serp/google.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { ProxyProvider } from '../../shared/services/proxy-provider';
|
|
| 16 |
|
| 17 |
@singleton()
|
| 18 |
export class GoogleSERP extends AsyncService {
|
| 19 |
-
|
| 20 |
googleDomain = process.env.OVERRIDE_GOOGLE_DOMAIN || 'www.google.com';
|
| 21 |
|
| 22 |
constructor(
|
|
@@ -36,7 +36,6 @@ export class GoogleSERP extends AsyncService {
|
|
| 36 |
this.emit('ready');
|
| 37 |
}
|
| 38 |
|
| 39 |
-
retryDet = new WeakSet<ScrappingOptions>();
|
| 40 |
@retryWith((err) => {
|
| 41 |
if (err instanceof ServiceBadApproachError) {
|
| 42 |
return false;
|
|
@@ -59,12 +58,7 @@ export class GoogleSERP extends AsyncService {
|
|
| 59 |
const proxy = await this.proxyProvider.alloc(
|
| 60 |
process.env.PREFERRED_PROXY_COUNTRY || 'auto'
|
| 61 |
);
|
| 62 |
-
|
| 63 |
-
if (this.retryDet.has(opts) && proxy.protocol === 'socks5h:') {
|
| 64 |
-
proxy.protocol = 'socks5:';
|
| 65 |
-
}
|
| 66 |
-
this.retryDet.add(opts);
|
| 67 |
-
}
|
| 68 |
const r = await this.curlControl.sideLoad(url, {
|
| 69 |
...opts,
|
| 70 |
proxyUrl: proxy.href,
|
|
|
|
| 16 |
|
| 17 |
@singleton()
|
| 18 |
export class GoogleSERP extends AsyncService {
|
| 19 |
+
logger = this.globalLogger.child({ service: this.constructor.name });
|
| 20 |
googleDomain = process.env.OVERRIDE_GOOGLE_DOMAIN || 'www.google.com';
|
| 21 |
|
| 22 |
constructor(
|
|
|
|
| 36 |
this.emit('ready');
|
| 37 |
}
|
| 38 |
|
|
|
|
| 39 |
@retryWith((err) => {
|
| 40 |
if (err instanceof ServiceBadApproachError) {
|
| 41 |
return false;
|
|
|
|
| 58 |
const proxy = await this.proxyProvider.alloc(
|
| 59 |
process.env.PREFERRED_PROXY_COUNTRY || 'auto'
|
| 60 |
);
|
| 61 |
+
this.logger.debug(`Proxy allocated`, { proxy: proxy.href });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
const r = await this.curlControl.sideLoad(url, {
|
| 63 |
...opts,
|
| 64 |
proxyUrl: proxy.href,
|
thinapps-shared
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
Subproject commit
|
|
|
|
| 1 |
+
Subproject commit 424f50ca8b6277d74185e16aa67ff2b366d9f727
|