headless
This commit is contained in:
@@ -390,13 +390,31 @@ class BTGoScraper:
|
||||
# display): viewport-ul setat pe context (CSS) nu se propaga la
|
||||
# fereastra fizica, iar BT afiseaza un splash "redirect to store"
|
||||
# sub ~1100px care ascunde input#user.
|
||||
launch_args = ['--window-size=1920,1080']
|
||||
context_kwargs = {'viewport': {'width': 1920, 'height': 1080}}
|
||||
|
||||
if self.config.HEADLESS:
|
||||
# Playwright 1.48: headless=True foloseste VECHIUL mod headless,
|
||||
# blocat de WAF-ul Akamai al BT. Fortam NOUL mod headless
|
||||
# (--headless=new) cu headless=False ca Playwright sa nu adauge
|
||||
# --headless=old. Randeaza ca un Chrome real, fara fereastra ->
|
||||
# CPU mult mai mic decat headed software-rendering in session 0.
|
||||
launch_args.append('--headless=new')
|
||||
# UA-ul noului mod headless contine 'HeadlessChrome' - semnatura
|
||||
# pe care o detecteaza Akamai. Il inlocuim cu UA de Chrome normal.
|
||||
context_kwargs['user_agent'] = (
|
||||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
|
||||
'AppleWebKit/537.36 (KHTML, like Gecko) '
|
||||
'Chrome/130.0.0.0 Safari/537.36'
|
||||
)
|
||||
|
||||
browser = p.chromium.launch(
|
||||
headless=self.config.HEADLESS,
|
||||
slow_mo=100 if not self.config.HEADLESS else 0,
|
||||
args=['--window-size=1920,1080']
|
||||
headless=False,
|
||||
slow_mo=0 if self.config.HEADLESS else 100,
|
||||
args=launch_args,
|
||||
)
|
||||
|
||||
context = browser.new_context(viewport={'width': 1920, 'height': 1080})
|
||||
context = browser.new_context(**context_kwargs)
|
||||
|
||||
# Blocheaza trackere care fac polling continuu pe homepage BT si
|
||||
# pun renderer-ul la 80-100% CPU pe hardware slab. Nu sunt folosite
|
||||
|
||||
Reference in New Issue
Block a user