Merge pull request #125 from samip5/configureable_user_agent
Ability to pass custom user agent to the scraper and ignore .git on Docker
This commit is contained in:
commit
bf86e0d36a
|
@ -1,5 +1,6 @@
|
||||||
node_modules
|
node_modules
|
||||||
/.env
|
/.env
|
||||||
|
/.git
|
||||||
/.vscode
|
/.vscode
|
||||||
/vendor
|
/vendor
|
||||||
/cache/latte/*
|
/cache/latte/*
|
||||||
|
|
|
@ -20,3 +20,5 @@
|
||||||
# PROXY_PORT=8080
|
# PROXY_PORT=8080
|
||||||
# PROXY_USERNAME=username
|
# PROXY_USERNAME=username
|
||||||
# PROXY_PASSWORD=password
|
# PROXY_PASSWORD=password
|
||||||
|
|
||||||
|
# USER_AGENT="Mozilla/5.0 (Android 12; Mobile; rv:109.0) Gecko/109.0 Firefox/109.0"
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
namespace App\Controllers;
|
namespace App\Controllers;
|
||||||
|
|
||||||
use App\Helpers\Cookies;
|
use App\Helpers\Cookies;
|
||||||
|
use App\Helpers\Misc;
|
||||||
|
use TikScraper\Constants\UserAgents as TikScraperUserAgents;
|
||||||
|
|
||||||
class ProxyController {
|
class ProxyController {
|
||||||
const VALID_TIKTOK_DOMAINS = [
|
const VALID_TIKTOK_DOMAINS = [
|
||||||
|
@ -11,7 +13,8 @@ class ProxyController {
|
||||||
static public function stream() {
|
static public function stream() {
|
||||||
self::checkUrl();
|
self::checkUrl();
|
||||||
$url = $_GET['url'];
|
$url = $_GET['url'];
|
||||||
$streamer = new \TikScraper\Stream();
|
$config['user_agent'] = Misc::env("USER_AGENT", TikScraperUserAgents::DEFAULT);
|
||||||
|
$streamer = new \TikScraper\Stream($config);
|
||||||
$streamer->url($url);
|
$streamer->url($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ use App\Cache\RedisCache;
|
||||||
use App\Constants\CacheMethods;
|
use App\Constants\CacheMethods;
|
||||||
use App\Models\BaseTemplate;
|
use App\Models\BaseTemplate;
|
||||||
|
|
||||||
|
use TikScraper\Constants\UserAgents as TikScraperUserAgents;
|
||||||
|
|
||||||
class Wrappers {
|
class Wrappers {
|
||||||
/**
|
/**
|
||||||
* Setup of Latte template engine
|
* Setup of Latte template engine
|
||||||
|
@ -162,6 +164,8 @@ class Wrappers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$options["user_agent"] = Misc::env("USER_AGENT", TikScraperUserAgents::DEFAULT);
|
||||||
|
|
||||||
return new \TikScraper\Api($options, $cacheEngine);
|
return new \TikScraper\Api($options, $cacheEngine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue