Ability to pass own user agent to the scraper.

This commit is contained in:
Skyler Mäntysaari 2023-02-08 12:58:18 +02:00
parent 5dea2468f8
commit 3d5890d821
2 changed files with 5 additions and 1 deletions

View file

@ -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"

View file

@ -2,6 +2,7 @@
namespace App\Controllers; namespace App\Controllers;
use App\Helpers\Cookies; use App\Helpers\Cookies;
use App\Helpers\Misc;
class ProxyController { class ProxyController {
const VALID_TIKTOK_DOMAINS = [ const VALID_TIKTOK_DOMAINS = [
@ -11,7 +12,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", "Mozilla/5.0 (Android 12; Mobile; rv:109.0) Gecko/109.0 Firefox/109.0");
$streamer = new \TikScraper\Stream($config);
$streamer->url($url); $streamer->url($url);
} }