Repository navigation
Expand file tree
/
Copy pathadvanced_website_robot_v4.py
More file actions
7115 lines (5899 loc) · 347 KB
/
Copy pathadvanced_website_robot_v4.py
File metadata and controls
7115 lines (5899 loc) · 347 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
import random
import time
import logging
import sys
from urllib.parse import urlparse
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import TimeoutException, NoSuchElementException, WebDriverException
def setup_logging():
"""
Setup logging mengikuti pattern cookie_robot.py
"""
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setLevel(logging.INFO)
console_handler.setFormatter(logging.Formatter(
'%(asctime)s - %(name)s - %(lineno)s - %(levelname)s - %(message)s'))
logging.getLogger(name='advanced_website_robot').addHandler(console_handler)
class Configuration:
"""Advanced configuration management"""
def __init__(self):
self.config = {
'timing': {
'min_delay': random.uniform(0.3, 4.0), # Variasi yang lebih extreme
'max_delay': random.uniform(3.0, 30.0), # Range yang lebih extreme
'page_load_timeout': 30,
'element_wait_timeout': 10,
'long_pause_chance': random.uniform(0.02, 0.35), # Variasi chance lebih extreme
'long_pause_min': random.uniform(2.0, 10.0), # Variasi minimum pause lebih extreme
'long_pause_max': random.uniform(15.0, 60.0), # Variasi maximum pause lebih extreme
'human_typing_delay_range': (random.uniform(0.05, 0.5), random.uniform(0.3, 2.0)), # Variasi typing delays lebih extreme
'human_scroll_delay_range': (random.uniform(0.5, 5.0), random.uniform(3.0, 20.0)), # Variasi scroll delays lebih extreme
'human_click_delay_range': (random.uniform(0.2, 3.0), random.uniform(1.5, 15.0)), # Variasi click delays lebih extreme
'random_timing_variation': True, # Enable random timing variation
'natural_hesitation': True, # Enable natural hesitation
'reading_pause_chance': random.uniform(0.05, 0.50), # Variasi reading pause lebih extreme
'natural_timing_factor': random.uniform(0.5, 2.0), # Natural timing factor lebih extreme
'hesitation_variation': random.uniform(0.4, 2.0), # Hesitation variation lebih extreme
'micro_pause_chance': random.uniform(0.1, 0.4), # 10-40% chance micro pause
'macro_pause_chance': random.uniform(0.02, 0.15), # 2-15% chance macro pause
'distraction_pause_chance': random.uniform(0.05, 0.25), # 5-25% chance distraction pause
'natural_rhythm_factor': random.uniform(0.6, 1.8), # Natural rhythm factor
'timing_chaos_factor': random.uniform(0.1, 0.3) # 10-30% timing chaos
},
'stealth': {
'enable_stealth_scripts': True,
'advanced_evasion': True,
'behavioral_randomization': True
},
'behavior': {
'mouse_movement': True,
'random_delays': True,
'behavioral_profiles': ['exploratory', 'focused', 'wandering', 'hesitant', 'reading', 'distracted']
},
'reading': {
'min_reading_time': random.uniform(3.0, 5.0), # 3-5 minutes minimum
'max_reading_time': random.uniform(8.0, 12.0), # 8-12 minutes maximum
'default_reading_time': random.uniform(4.0, 6.0), # 4-6 minutes default
'content_type_detection': True, # Enable content type detection
'language_detection': True, # Enable language detection
'reading_speed_technical': (100, 150), # WPM for technical content
'reading_speed_news': (150, 200), # WPM for news content
'reading_speed_general': (150, 250), # WPM for general content
'indonesian_speed_multiplier': 0.8, # 20% slower for Indonesian
'english_speed_multiplier': 1.0, # Normal speed for English
'mood_change_chance': 0.03, # 3% chance to change reading mood
'micro_movement_chance': 0.3, # 30% chance for micro-movements
're_read_chance': 0.15, # 15% chance to re-read
'ad_check_interval_min': 120, # 2 minutes minimum
'ad_check_interval_max': 300, # 5 minutes maximum
'natural_reading_pauses': True, # Enable natural reading pauses
'comprehension_time': True, # Enable comprehension time
'mood_transitions': True, # Enable mood transition behavior
'pause_timing': {
'focused_pause_min': 1.0, # 1-3 seconds for focused reading
'focused_pause_max': 3.0,
'distracted_pause_min': 2.0, # 2-6 seconds for distracted reading
'distracted_pause_max': 6.0,
'careful_pause_min': 2.5, # 2.5-5 seconds for careful reading
'careful_pause_max': 5.0,
'quick_pause_min': 0.5, # 0.5-2 seconds for quick reading
'quick_pause_max': 2.0,
'distraction_chance': 0.15, # 15% chance for distraction pause
'distraction_pause_min': 3.0, # 3-8 seconds for distraction
'distraction_pause_max': 8.0,
'comprehension_chance': 0.20, # 20% chance for comprehension pause
'comprehension_pause_min': 2.0, # 2-6 seconds for comprehension
'comprehension_pause_max': 6.0,
're_read_pause_min': 0.5, # 0.5-2 seconds for re-reading
're_read_pause_max': 2.0,
'micro_pause_chance': 0.25, # 25% chance for micro-pause
'micro_pause_min': 0.2, # 0.2-1 second for micro-pause
'micro_pause_max': 1.0
},
'thinking': {
'enable_thinking': True, # Enable thinking behavior
'thinking_types': {
'quick_processing': {
'chance': 0.15, # 15% chance for quick processing
'pause_min': 0.5, # 0.5-2 seconds
'pause_max': 2.0,
'triggers': ['simple_content', 'familiar_topic']
},
'analytical_thinking': {
'chance': 0.20, # 20% chance for analytical thinking
'pause_min': 2.0, # 2-6 seconds
'pause_max': 6.0,
'triggers': ['complex_content', 'technical_topic']
},
'deep_contemplation': {
'chance': 0.08, # 8% chance for deep contemplation
'pause_min': 4.0, # 4-10 seconds
'pause_max': 10.0,
'triggers': ['important_content', 'new_concept']
},
'processing_information': {
'chance': 0.25, # 25% chance for processing
'pause_min': 1.5, # 1.5-4 seconds
'pause_max': 4.0,
'triggers': ['new_information', 'complex_sentence']
}
},
'thinking_context': {
'content_complexity_detection': True, # Detect content complexity
'topic_familiarity_detection': True, # Detect topic familiarity
'concept_importance_detection': True, # Detect concept importance
'sentence_complexity_detection': True # Detect sentence complexity
},
'thinking_patterns': {
'sequential_thinking': True, # Enable sequential thinking
'parallel_thinking': True, # Enable parallel thinking
'recursive_thinking': True, # Enable recursive thinking
'associative_thinking': True # Enable associative thinking
},
'thinking_behavior': {
'mouse_movement_during_thinking': True, # Mouse movement during thinking
'eye_tracking_simulation': True, # Simulate eye tracking
'micro_movements': True, # Micro-movements during thinking
'breathing_pattern_simulation': True # Simulate breathing patterns
}
}
},
'risk': {
'max_requests_per_minute': 30,
'detection_threshold': 0.7,
'cooldown_period': 60,
'emergency_protocol_threshold': 0.9,
'slow_down_threshold': 0.6
},
'ad_clicking': {
'enabled': True,
# 'click_chance': random.uniform(0.01, 0.25), # Variasi chance 1-25% (lebih extreme)
# 'max_clicks_per_session': random.randint(0, 8), # Variasi jumlah 0-8 (termasuk 0)
'click_chance': random.uniform(0.05, 0.4), # Ditingkatkan ke 5-40% untuk lebih efektif
'max_clicks_per_session': random.randint(1, 5), # Ditingkatkan ke 1-5 untuk lebih efektif
'conservative_mode': True,
'ad_types': ['google_adsense', 'google_vignette', 'google_discovery'], # Based on sample files analysis
# 'rate_limit_window': random.randint(900, 4800), # Variasi window 15-80 menit (lebih extreme)
# 'max_clicks_per_window': random.randint(0, 5), # Variasi max clicks 0-5 (termasuk 0)
'rate_limit_window': random.randint(1800, 7200), # Ditingkatkan ke 30-120 menit untuk lebih aman
'max_clicks_per_window': random.randint(0, 2), # Dikurangi ke 0-2 untuk lebih konservatif
'human_like_hesitation': True, # Add human hesitation
'random_click_timing': True, # Randomize click timing
'natural_reading_before_click': True, # Read before clicking
'random_skip_ads': True, # Skip ads secara random
'natural_hesitation': True, # Tambahkan hesitation
# 'variation_factor': random.uniform(0.5, 1.8), # Variasi factor lebih extreme
# 'session_skip_chance': random.uniform(0.1, 0.4), # 10-40% chance skip entire session
# 'ad_avoidance_pattern': random.choice(['conservative', 'moderate', 'aggressive']), # Avoidance pattern
# 'click_hesitation_factor': random.uniform(0.3, 2.0), # Hesitation factor
'variation_factor': random.uniform(0.3, 1.2), # Dikurangi untuk lebih konservatif
'session_skip_chance': random.uniform(0.05, 0.2), # Dikurangi ke 5-20% untuk lebih efektif
'ad_avoidance_pattern': random.choice(['conservative', 'moderate']), # Hapus 'aggressive' untuk lebih aman
'click_hesitation_factor': random.uniform(0.5, 3.0), # Ditingkatkan hesitation
'invalid_traffic_protection': True, # Tambahkan proteksi invalid traffic
'min_session_duration': random.uniform(5, 15), # Minimal 5-15 detik session (reduced)
'max_daily_clicks': random.randint(10, 25), # Maksimal 10-25 klik per hari (increased)
'natural_bounce_rate': random.uniform(0.3, 0.7), # Bounce rate natural 30-70%
'reading_time_before_click': random.uniform(3, 15), # Baca 3-15 detik sebelum klik
'natural_error_rate': random.uniform(0.05, 0.25) # 5-25% natural error rate
},
'navigation': {
'enabled': True,
'max_navigation_depth': 3,
'same_domain_preference': 0.8,
'random_link_clicking': True
},
'article': {
'default_urls': [
# 'https://rexdl.biz.id/cloud-computing-cost-optimization-how-us-companies-cut-expenses/',
# 'https://rexdl.biz.id/why-cloud-computing-is-the-backbone-of-us-healthcare-industry/',
# 'https://rexdl.biz.id/best-cloud-hosting-providers-for-small-businesses-in-america/',
# 'https://rexdl.biz.id/top-10-cloud-computing-services-for-businesses-in-the-united-states/',
# 'https://rexdl.biz.id/personal-loans-vs-private-student-loans-comparing-cost-interest-and-repayment-options/',
# 'https://rexdl.biz.id/quick-cash-loans-explained-how-they-work-what-they-really-cost-safer-alternatives/',
# 'https://rexdl.biz.id/life-insurance-rates-comparison-the-complete-guide-for-u-s-families-in-2025/',
# 'https://rexdl.biz.id/how-to-find-cheap-auto-insurance-quotes-in-the-u-s-the-complete-practical-guide/',
# 'https://rexdl.biz.id/ai-for-small-business-the-ultimate-guide-to-growth-efficiency-and-profit-in-2025/',
# 'https://tokenomics.web.id/tokenomics-bitcoin-btc-apakah-fixed-supply-selalu-aman/',
# 'https://tokenomics.web.id/bagaimana-tokenomics-solana-sol-mendorong-skalabilitas/',
# 'https://tokenomics.web.id/tokenomics-polygon-matic-layer-2-yang-menjanjikan/',
# 'https://tokenomics.web.id/tokenomics-shiba-inu-shib-apakah-burn-rate-mampu-naikkan-harga/',
# 'https://tokenomics.web.id/cara-membaca-tokenomics-sebelum-investasi-kripto-panduan-2025/',
# 'https://tokenomics.web.id/peran-bappebti-dalam-mengawasi-aset-kripto-di-indonesia/',
# 'https://primecapitalaid.web.id/cara-mendapatkan-bantuan-modal-usaha-umkm-tahun-2025-ulasan-teknis-uji-lapangan-dan-tips-lolos-seleksi/',
# 'https://primecapitalaid.web.id/bantuan-modal-umkm-khusus-perempuan-program-dan-syaratnya/',
# 'https://primecapitalaid.web.id/apa-itu-pinjaman-legal-ini-ciri-cirinya-yang-harus-anda-ketahui/',
# 'https://primecapitalaid.web.id/pinjaman-untuk-umkm-usaha-kecil-rekomendasi-pinjaman-legal-terdaftar-ojk-2025/',
'https://setiap.zonagamegratisan.com/dana-mudah-cair-online-aman-terdaftar-ojk/',
'https://setiap.zonagamegratisan.com/dana-mudah-cair-tunaiku/',
'https://setiap.zonagamegratisan.com/pinjaman-online-di-tahun-2025-danamas/',
'https://cekmedia.com/pinjaman-online-langsung-cair-ke-rekening-tanpa-verifikasi-wajah-solusi-cepat-aman-di-2025-gendon/',
'https://cekmedia.com/7-apk-pinjaman-bunga-rendah-terbaik-terpercaya-2025-pilihan-aman-tips-pengajuan-dan-daftar-legal-ojk/',
'https://cekmedia.com/pinjaman-online-untuk-umkm-rekomendasi-aplikasi-terbaik-uji-langsung-dan-review-real-pengguna/',
'https://pintar.cekmedia.com/rekomendasi-pinjaman-online-untuk-karyawan-gaji-umr-update-2025/',
'https://pintar.cekmedia.com/cara-menghindari-pinjaman-online-ilegal-dan-penipuan-digital-panduan-2025/',
# 'https://maxgaming.biz.id/how-to-open-a-bank-account-with-crypto-funds-in-the-united-states-2025-guide/',
# 'https://maxgaming.biz.id/online-mortgage-banking-with-bitcoin-the-future-of-real-estate-in-the-united-states/',
# 'https://maxgaming.biz.id/artificial-intelligence-in-healthcare-transforming-us-medicine/',
# 'https://maxgaming.biz.id/how-ai-automation-saves-time-and-money-for-us-businesses/',
# 'https://tokenomics.web.id/tokenomics-bitcoin-btc-apakah-fixed-supply-selalu-aman/',
# 'https://tokenomics.web.id/bagaimana-tokenomics-solana-sol-mendorong-skalabilitas/',
# 'https://tokenomics.web.id/tokenomics-polygon-matic-layer-2-yang-menjanjikan/',
# 'https://tokenomics.web.id/7-langkah-analisis-token-yang-wajib-kamu-lakukan-sebelum-membeli-panduan-2025/',
# 'https://tokenomics.web.id/cara-menilai-proyek-kripto-dari-distribusi-token-nya-panduan-2025/',
# 'https://gradua.web.id/bunga-0-3-bulan-pertama-untuk-pendaftar-baru',
# 'https://gradua.web.id/pinjaman-darurat-ojk-cair-5-menit-ke-rekening-tanpa-jaminan',
# 'https://gradua.web.id/cara-meminjam-uang-di-bank-untuk-modal-usaha-panduan-lengkap-dan-praktis',
# 'https://gradua.web.id/syarat-pinjaman-kur-2025-terbaru-panduan-lengkap-dan-lengkap-untuk-pengusaha',
# 'https://gradua.web.id/prediksi-pakar-ai-coin-ini-bisa-tembus-rp754-juta-per-koin-di-2030-simulasi-portofolio-2025',
# 'https://gradua.web.id/gila-roi-7-598-5-ai-coin-terbaik-2025-bittensor-render-network-paling-moncer',
# 'https://gradua.web.id/dari-rp500-ribu-jadi-milyaran-blueprint-investasi-ai-coin-untuk-pemula-2025',
# 'https://primecapitalaid.web.id/cara-mendapatkan-bantuan-modal-usaha-umkm-tahun-2025-ulasan-teknis-uji-lapangan-dan-tips-lolos-seleksi',
# 'https://primecapitalaid.web.id/program-bantuan-modal-untuk-usaha-mikro-kecil-syarat-cara-pengajuan/',
# 'https://primecapitalaid.web.id/bantuan-modal-umkm-khusus-perempuan-program-dan-syaratnya/',
# 'https://primecapitalaid.web.id/apa-itu-pinjaman-legal-ini-ciri-cirinya-yang-harus-anda-ketahui/',
# 'https://primecapitalaid.web.id/pinjaman-untuk-umkm-usaha-kecil-rekomendasi-pinjaman-legal-terdaftar-ojk-2025/',
# 'https://primecapitalaid.web.id/program-pinjaman-legal-dari-pemerintah-untuk-umkm-2025/',
# 'https://primecapitalaid.web.id/apa-itu-investasi-panduan-lengkap-untuk-pemula-yang-ingin-merdeka-finansial-di-2025/',
# 'https://primecapitalaid.web.id/apa-itu-literasi-keuangan-dan-mengapa-penting-panduan-komprehensif-melek-finansial-di-era-digital/',
# 'https://setiap.zonagamegratisan.com/11-aplikasi-penghasil-uang-100-ribu-perhari/',
# 'https://setiap.zonagamegratisan.com/aplikasi-penghasil-uang-2025-yougov/',
# 'https://setiap.zonagamegratisan.com/aplikasi-penghasil-uang-tahun-2025/',
# 'https://setiap.zonagamegratisan.com/dana-mudah-cair-julo-kredit-digital/',
# 'https://setiap.zonagamegratisan.com/aplikasi-yang-langsung-memberikan-saldo-dana-gratis/',
# 'https://setiap.zonagamegratisan.com/dana-mudah-cair-online-aman-terdaftar-ojk/',
],
'default_referers': [
# High CPC referers (Business/Finance/Tech)
'https://google.com', 'https://bing.com',
# 'https://linkedin.com', 'https://github.com', 'https://stackoverflow.com',
# 'https://medium.com', 'https://quora.com', 'https://forbes.com',
# 'https://bloomberg.com', 'https://reuters.com', 'https://wsj.com',
# 'https://techcrunch.com', 'https://wired.com', 'https://arstechnica.com',
# 'https://hbr.org', 'https://mckinsey.com', 'https://pwc.com',
# 'https://deloitte.com', 'https://kpmg.com', 'https://ey.com',
# 'https://ibm.com', 'https://microsoft.com', 'https://oracle.com',
# 'https://salesforce.com', 'https://adobe.com', 'https://intel.com',
# 'https://nvidia.com', 'https://amd.com', 'https://cisco.com',
# 'https://aws.amazon.com', 'https://cloud.google.com', 'https://azure.microsoft.com',
# 'https://hubspot.com',
# # Additional Business/Finance referers
# 'https://cnbc.com', 'https://marketwatch.com', 'https://investing.com',
# 'https://yahoo.com/finance', 'https://finance.yahoo.com', 'https://seekingalpha.com',
# 'https://benzinga.com', 'https://fool.com', 'https://morningstar.com',
# 'https://nasdaq.com', 'https://nyse.com', 'https://sec.gov',
# 'https://federalreserve.gov', 'https://treasury.gov', 'https://irs.gov',
# 'https://sba.gov', 'https://ftc.gov', 'https://sec.gov',
# 'https://finra.org', 'https://cftc.gov', 'https://fdic.gov',
# 'https://occ.gov', 'https://federalreserve.gov', 'https://treasury.gov',
# # Financial Services & Banking
# 'https://jpmorgan.com', 'https://bankofamerica.com', 'https://wellsfargo.com',
# 'https://citigroup.com', 'https://goldmansachs.com', 'https://morganstanley.com',
# 'https://blackrock.com', 'https://vanguard.com', 'https://fidelity.com',
# 'https://schwab.com', 'https://etrade.com', 'https://tdameritrade.com',
# 'https://interactivebrokers.com', 'https://robinhood.com', 'https://webull.com',
# 'https://sofi.com', 'https://chase.com', 'https://capitalone.com',
# 'https://americanexpress.com', 'https://visa.com', 'https://mastercard.com',
# 'https://paypal.com', 'https://square.com', 'https://stripe.com',
# # Investment & Trading Platforms
# 'https://etrade.com', 'https://schwab.com', 'https://fidelity.com',
# 'https://vanguard.com', 'https://blackrock.com', 'https://goldmansachs.com',
# 'https://morganstanley.com', 'https://jpmorgan.com', 'https://citigroup.com',
# 'https://wellsfargo.com', 'https://bankofamerica.com', 'https://chase.com',
# 'https://robinhood.com', 'https://webull.com', 'https://sofi.com',
# 'https://interactivebrokers.com', 'https://tdameritrade.com', 'https://etrade.com',
# 'https://trading212.com', 'https://plus500.com', 'https://ig.com',
# 'https://oanda.com', 'https://forex.com', 'https://fxcm.com',
# # Business News & Media
# 'https://businesswire.com', 'https://prnewswire.com', 'https://globenewswire.com',
# 'https://marketwatch.com', 'https://investing.com', 'https://benzinga.com',
# 'https://seekingalpha.com', 'https://fool.com', 'https://morningstar.com',
# 'https://nasdaq.com', 'https://nyse.com', 'https://otcmarkets.com',
# 'https://sec.gov', 'https://federalreserve.gov', 'https://treasury.gov',
# 'https://irs.gov', 'https://sba.gov', 'https://ftc.gov',
# 'https://finra.org', 'https://cftc.gov', 'https://fdic.gov',
# # Technology & Innovation
# 'https://apple.com', 'https://google.com', 'https://microsoft.com',
# 'https://amazon.com', 'https://meta.com', 'https://netflix.com',
# 'https://tesla.com', 'https://spacex.com', 'https://openai.com',
# 'https://anthropic.com', 'https://deepmind.com', 'https://nvidia.com',
# 'https://amd.com', 'https://intel.com', 'https://qualcomm.com',
# 'https://broadcom.com', 'https://cisco.com', 'https://juniper.net',
# 'https://vmware.com', 'https://redhat.com', 'https://canonical.com',
# 'https://docker.com', 'https://kubernetes.io', 'https://terraform.io',
# # Cloud & Enterprise Software
# 'https://aws.amazon.com', 'https://cloud.google.com', 'https://azure.microsoft.com',
# 'https://salesforce.com', 'https://oracle.com', 'https://sap.com',
# 'https://workday.com', 'https://servicenow.com', 'https://atlassian.com',
# 'https://slack.com', 'https://zoom.us', 'https://teams.microsoft.com',
# 'https://dropbox.com', 'https://box.com', 'https://onedrive.com',
# 'https://sharepoint.com', 'https://office.com', 'https://adobe.com',
# 'https://autodesk.com', 'https://ansys.com', 'https://solidworks.com',
# 'https://tableau.com', 'https://powerbi.com', 'https://qlik.com',
# # Cybersecurity & Data
# 'https://crowdstrike.com', 'https://paloaltonetworks.com', 'https://fortinet.com',
# 'https://checkpoint.com', 'https://symantec.com', 'https://mcafee.com',
# 'https://trendmicro.com', 'https://kaspersky.com', 'https://bitdefender.com',
# 'https://splunk.com', 'https://elastic.co', 'https://databricks.com',
# 'https://snowflake.com', 'https://mongodb.com', 'https://redis.com',
# 'https://postgresql.org', 'https://mysql.com', 'https://oracle.com',
# 'https://ibm.com', 'https://hpe.com', 'https://dell.com',
# # Consulting & Professional Services
# 'https://mckinsey.com', 'https://bain.com', 'https://bcg.com',
# 'https://pwc.com', 'https://deloitte.com', 'https://kpmg.com',
# 'https://ey.com', 'https://accenture.com', 'https://cognizant.com',
# 'https://infosys.com', 'https://tcs.com', 'https://wipro.com',
# 'https://capgemini.com', 'https://atos.net', 'https://dxc.com',
# 'https://hcl.com', 'https://techmahindra.com', 'https://mindtree.com',
# 'https://ltts.com', 'https://mphasis.com', 'https://hexaware.com',
# # Venture Capital & Startups
# 'https://a16z.com', 'https://sequoiacap.com', 'https://accel.com',
# 'https://greylock.com', 'https://benchmark.com', 'https://kleinerperkins.com',
# 'https://firstround.com', 'https://foundersfund.com', 'https://union.vc',
# 'https://insightpartners.com', 'https://generalcatalyst.com', 'https://bessemer.com',
# 'https://lightspeed.com', 'https://matrixpartners.com', 'https://redpoint.com',
# 'https://nea.com', 'https://battery.com', 'https://ivp.com',
# 'https://ggv.com', 'https://dcm.com', 'https://sapphire.com',
# # Medium CPC referers (General/Social)
# 'https://reddit.com', 'https://twitter.com', 'https://facebook.com',
# 'https://instagram.com', 'https://youtube.com', 'https://tiktok.com',
# 'https://pinterest.com', 'https://snapchat.com', 'https://discord.com',
# 'https://slack.com', 'https://zoom.us', 'https://teams.microsoft.com',
# # Educational/Research referers
# 'https://wikipedia.org', 'https://scholar.google.com', 'https://researchgate.net',
# 'https://academia.edu', 'https://coursera.org', 'https://edx.org',
# 'https://udemy.com', 'https://khanacademy.org', 'https://mit.edu',
# 'https://stanford.edu', 'https://harvard.edu', 'https://berkeley.edu',
# # News/Media referers
# 'https://cnn.com', 'https://bbc.com', 'https://nytimes.com',
# 'https://washingtonpost.com', 'https://usatoday.com', 'https://npr.org',
# 'https://ap.org', 'https://aljazeera.com', 'https://theguardian.com',
# 'https://independent.co.uk', 'https://telegraph.co.uk', 'https://ft.com',
'https://www.coindesk.com/markets/2025/09/15/dogecoin-inches-closer-to-wall-street-with-first-meme-coin-etf',
'https://www.coindesk.com/business/2025/09/18/ripple-franklin-templeton-and-dbs-to-offer-token-lending-and-trading',
'https://coinledger.io/tools/best-crypto-wallet',
'https://money.com/best-crypto-wallets/',
'https://shop.ledger.com/products/ledger-flex/graphite',
'https://hellopebl.com/resources/blog/best-crypto-wallets/',
'https://www.forbes.com/advisor/investing/cryptocurrency/best-crypto-wallets/',
'https://www.nerdwallet.com/p/best/investing/crypto-bitcoin-wallets',
'https://bravenewcoin.com/insights/ethereum-eth-price-prediction-ethereum-eyes-5000-as-bullish-cross-meets-fed-rate-cut-speculation',
'https://cointelegraph.com/news/price-predictions-917-btc-eth-xrp-bnb-sol-doge-ada-hype-link-sui',
'https://coinledger.io/tools/best-crypto-portfolio-tracker',
'https://www.litrg.org.uk/savings-property/cryptoassets-and-tax',
#insurance
'https://www.usnews.com/insurance/auto/geico-vs-progressive',
'https://www.cnbc.com/select/geico-vs-progressive-car-insurance-which-is-better/',
'https://www.bankrate.com/insurance/reviews/geico-vs-progressive/#is-geico-cheaper-than-progressive',
'https://www.forbes.com/advisor/car-insurance/geico-vs-progressive-car-insurance/',
'https://ca.trustpilot.com/review/www.statefarm.com',
'https://www.usnews.com/insurance/auto/state-farm-car-insurance-review',
'https://www.bankrate.com/insurance/reviews/state-farm/#car-insurance',
'https://www.allstate.ca/car-insurance',
'https://www.allstate.com/auto-insurance',
'https://www.usaa.com',
'https://www.usaa.com/insurance/pilot-state?bundlingIntent=auto&wa_ref=pub_home_tiles_ins_veh_auto_quote',
'https://www.usaa.com/insurance/life/',
],
'high_cpc_weight': 0.9, # 70% chance to select high CPC referers
'use_referer': True, # Enable/disable referer usage
'referer_method': 'auto', # 'auto', 'real', 'proxy', 'cdp', 'direct'
'mix_direct_referer': True, # Enable mix of direct and referer traffic
'direct_ratio': 0.3, # 30% direct, 70% referer (when mix enabled)
'natural_pattern': True # Use natural traffic patterns
}
}
def get(self, key_path, default=None):
keys = key_path.split('.')
value = self.config
for key in keys:
if isinstance(value, dict) and key in value:
value = value[key]
else:
return default
return value
class TimingSystem:
"""Advanced timing system with human-like behavior"""
def __init__(self):
self.config = Configuration()
self.last_action_time = 0
self.action_history = []
self.base_delay = 1.0
self.delay_variability = 0.7
self.long_pause_chance = self.config.get('timing.long_pause_chance', 0.05)
self.long_pause_min = self.config.get('timing.long_pause_min', 3.0)
self.long_pause_max = self.config.get('timing.long_pause_max', 8.0)
def advanced_random_delay(self, base_delay=None, variability=None):
"""Generate advanced random delay with more natural variation"""
if base_delay is None:
base_delay = self.base_delay
if variability is None:
variability = self.delay_variability
# Check for long pause chance with more natural variation
if random.random() < self.long_pause_chance:
long_pause = random.uniform(self.long_pause_min, self.long_pause_max)
# Add random micro-pauses within long pause
if random.random() < 0.3: # 30% chance of micro-pause
long_pause += random.uniform(0.5, 2.0)
return long_pause
# Generate delay with more natural distribution
delay = random.normalvariate(base_delay, base_delay * variability)
# Add natural hesitation patterns with extreme config variation
hesitation_variation = self.config.get('timing.hesitation_variation', random.uniform(0.4, 2.0))
if random.random() < 0.35: # 35% chance of hesitation
delay += random.uniform(0.2, 3.0) * hesitation_variation
# Add natural timing factor from config
natural_timing_factor = self.config.get('timing.natural_timing_factor', random.uniform(0.5, 2.0))
delay *= natural_timing_factor
# Add micro-pause chance
micro_pause_chance = self.config.get('timing.micro_pause_chance', random.uniform(0.1, 0.4))
if random.random() < micro_pause_chance:
delay += random.uniform(0.1, 0.8)
# Add macro-pause chance
macro_pause_chance = self.config.get('timing.macro_pause_chance', random.uniform(0.02, 0.15))
if random.random() < macro_pause_chance:
delay += random.uniform(2.0, 8.0)
# Add distraction pause chance
distraction_pause_chance = self.config.get('timing.distraction_pause_chance', random.uniform(0.05, 0.25))
if random.random() < distraction_pause_chance:
delay += random.uniform(1.0, 5.0)
# Add natural rhythm factor
natural_rhythm_factor = self.config.get('timing.natural_rhythm_factor', random.uniform(0.6, 1.8))
delay *= natural_rhythm_factor
# Add timing chaos factor
timing_chaos_factor = self.config.get('timing.timing_chaos_factor', random.uniform(0.1, 0.3))
if random.random() < timing_chaos_factor:
delay *= random.uniform(0.3, 3.0) # Extreme chaos
# Add micro-variations for more natural feel
micro_variation = random.uniform(0.6, 1.6)
delay *= micro_variation
# Ensure minimum delay
delay = max(0.2, delay)
return delay
def human_like_delay(self, delay_type="normal"):
"""Generate more human-like delays with imperfections"""
if delay_type == "typing":
# Add typing mistakes and corrections
if random.random() < 0.15: # 15% chance of hesitation
return random.uniform(0.5, 2.0) # Longer pause for thinking
if random.random() < 0.08: # 8% chance of typing mistake
return random.uniform(0.8, 1.5) # Time to correct mistake
delay_range = (0.08, 0.4) # More variation in typing speed
delay = random.uniform(*delay_range)
elif delay_type == "scrolling":
# Add reading pauses
if random.random() < 0.3: # 30% chance of reading pause
return random.uniform(3, 8) # Reading pause
if random.random() < 0.1: # 10% chance of distraction
return random.uniform(5, 15) # Distraction pause
delay_range = (0.8, 6.0) # More variation in scroll timing
delay = random.uniform(*delay_range)
elif delay_type == "clicking":
# Add hesitation before clicking
if random.random() < 0.2: # 20% chance of hesitation
return random.uniform(1.5, 4.0) # Hesitation pause
if random.random() < 0.05: # 5% chance of double-click attempt
return random.uniform(0.1, 0.3) # Quick double-click timing
delay_range = (0.3, 2.5) # More variation in click timing
delay = random.uniform(*delay_range)
elif delay_type == "reading":
# Reading-specific delays
if random.random() < 0.4: # 40% chance of reading pause
return random.uniform(2, 6) # Reading content
if random.random() < 0.15: # 15% chance of re-reading
return random.uniform(1, 3) # Re-reading pause
delay_range = (0.5, 3.0) # General reading timing
delay = random.uniform(*delay_range)
else:
# Add random human imperfections
base_delay = random.uniform(0.5, 3.0)
if random.random() < 0.1: # 10% chance of long pause
return random.uniform(5, 15) # Distraction pause
if random.random() < 0.05: # 5% chance of very short pause
return random.uniform(0.1, 0.3) # Quick action
delay = base_delay
return delay
def get_human_delay(self, base_delay=None):
if base_delay is None:
base_delay = random.uniform(
self.config.get('timing.min_delay', 0.5),
self.config.get('timing.max_delay', 3.0)
)
# Add variation based on action history
if len(self.action_history) > 3:
recent_avg = sum(self.action_history[-3:]) / 3
variation = random.uniform(0.8, 1.2)
base_delay = recent_avg * variation
self.action_history.append(base_delay)
if len(self.action_history) > 10:
self.action_history.pop(0)
return base_delay
def wait_between_actions(self, min_delay=0.5, max_delay=3.0):
delay = self.get_human_delay(random.uniform(min_delay, max_delay))
time.sleep(delay)
return delay
class DetectionPatterns:
"""Advanced detection patterns for various elements"""
def __init__(self):
self.ad_detection_patterns = {
'google_adsense': [
# Priority 1: Filled ads only (most specific)
'ins.adsbygoogle[data-ad-status="filled"]',
'ins.adsbygoogle[data-adsbygoogle-status="done"][data-ad-status="filled"]',
# Priority 2: Specific AdSense elements with client and slot
'ins.adsbygoogle[data-ad-client][data-ad-slot]',
'ins.adsbygoogle[data-ad-client="ca-pub-"][data-ad-slot]',
# Priority 3: AdSense with specific format
'ins.adsbygoogle[data-ad-format="auto"]',
'ins.adsbygoogle[data-ad-format="rectangle"]',
'ins.adsbygoogle[data-ad-format="banner"]',
# Priority 4: Container divs with specific IDs (from samples)
'div[id*="aswift"][id*="host"]', # aswift_1_host, aswift_2_host, etc.
'iframe[id*="aswift"][id*="aswift_"]', # aswift_1, aswift_2, etc.
# Priority 5: Auto-placed containers with ads
'div.google-auto-placed ins.adsbygoogle',
'div.ap_container ins.adsbygoogle'
],
'google_adsense_exclude': [
# Exclude unfilled ads (most important)
'ins[data-ad-status="unfilled"]',
'ins.adsbygoogle[data-ad-status="unfilled"]',
'ins.adsbygoogle-noablate[data-ad-status="unfilled"]',
# Exclude auto-placed ads that are unfilled
'div.google-auto-placed ins[data-ad-status="unfilled"]',
'div.ap_container ins[data-ad-status="unfilled"]',
# Exclude hidden ads
'ins[style*="display: none"]',
'ins[style*="height: 0"]',
'ins[style*="width: 0"]',
# Exclude ads with opacity 0
'ins[style*="opacity: 0"]',
'div[style*="opacity: 0"]',
# Exclude ads with undefined dimensions
'ins[style*="width: undefined"]',
'ins[style*="height: undefined"]',
# Exclude navigation elements that might be detected as ads
'a[href*="/pinjaman-online"]',
'a[href*="/dana-mudah-cair"]',
'a[href*="/pinjaman"]',
'a[href*="/kredit"]',
'a[href*="/modal"]',
'a[href*="/bantuan"]',
'a[href*="/usaha"]',
'a[href*="/investasi"]',
'a[href*="/finansial"]',
'a[href*="/keuangan"]',
'a[href*="setiap.zonagamegratisan.com"]',
'a[href*="zonagamegratisan.com"]',
'a[href*="primecapitalaid.web.id"]',
'a[href*="tokenomics.web.id"]',
'a[href*="gradua.web.id"]',
# Exclude related posts section
'.idblog-related-post a',
'.related-title + ul a',
'h3.related-title + ul a',
'.idblog-core a',
'.idblog-related-post li a'
],
'google_vignette': [
# Based on actual analysis of vigennet.html
# Auto-placed ads with noablate class (vignette ads)
'ins.adsbygoogle.adsbygoogle-noablate',
'ins.adsbygoogle-noablate',
'ins[class*="adsbygoogle-noablate"]',
# Auto-placed containers with vignette ads
'div.google-auto-placed ins.adsbygoogle-noablate',
'div.ap_container ins.adsbygoogle-noablate',
# Vignette ads with specific attributes
'ins.adsbygoogle-noablate[data-ad-format="auto"]',
'ins.adsbygoogle-noablate[data-ad-client]',
'ins.adsbygoogle-noablate[data-ad-slot]',
# Vignette ads with status
'ins.adsbygoogle-noablate[data-ad-status="filled"]',
'ins.adsbygoogle-noablate[data-ad-status="unfilled"]',
'ins.adsbygoogle-noablate[data-adsbygoogle-status="done"]'
],
'google_discovery': [
# Based on actual analysis of sample2.html
# Related Topics Widget (found in sample2.html)
'.goog-rtopics',
'div.goog-rtopics',
'[class*="goog-rtopics"]',
'div[class*="goog-rtopics"][aria-label*="topics"]',
'div[class*="goog-rtopics"][tabindex]',
'div[class*="goog-rtopics"][aria-label*="related"]'
],
}
self.captcha_patterns = [
'#captcha', '.captcha', '.g-recaptcha', '[data-sitekey]',
'.recaptcha', '[data-testid*="captcha"]'
]
self.navigation_patterns = {
'next': [
# Standard navigation
'a[rel="next"]',
'.next',
'.next-page',
'[aria-label*="next"]',
'a:contains("Next")',
'a:contains(">")',
# WordPress theme navigation (from sample.html analysis)
'.idblog-related-post a',
'.related-title + ul a',
'h3.related-title + ul a',
'.idblog-core a',
'.idblog-related-post li a',
# Navigation buttons
'.nav-next',
'.navigation-next',
'.pagination-next',
'.page-next',
'.btn-next',
'.button-next',
# Arrow navigation
'a:contains(">")', # instead of right arrow
'a:contains(">>")', # instead of double right arrow
'a:contains(">")', # instead of single right arrow
'a:contains(">")', # instead of play button
'a:contains(">")', # instead of triangle right
],
'previous': [
# Standard navigation
'a[rel="prev"]',
'.prev',
'.previous',
'.previous-page',
'[aria-label*="previous"]',
'a:contains("Previous")',
'a:contains("<")',
# WordPress theme navigation
'.idblog-related-post a',
'.related-title + ul a',
'h3.related-title + ul a',
'.idblog-core a',
'.idblog-related-post li a',
# Navigation buttons
'.nav-prev',
'.navigation-prev',
'.pagination-prev',
'.page-prev',
'.btn-prev',
'.button-prev',
# Arrow navigation
'a:contains("<")', # instead of left arrow
'a:contains("<<")', # instead of double left arrow
'a:contains("<")', # instead of single left arrow
'a:contains("<")', # instead of play button left
'a:contains("<")' # instead of triangle left
]
}
self.behavioral_anomaly_patterns = [
'webdriver',
'selenium',
'phantomjs',
'headless',
'automation'
]
class MouseMovementSimulator:
"""Advanced mouse movement simulation"""
def __init__(self, driver):
self.driver = driver
self.config = Configuration()
self.movement_history = []
def human_like_movement(self, start_pos, end_pos, steps=None):
"""More human-like mouse movement with natural imperfections"""
if steps is None:
distance = ((end_pos[0] - start_pos[0])**2 + (end_pos[1] - start_pos[1])**2)**0.5
# More natural step calculation with extreme random variation
base_steps = max(3, min(120, int(distance / 12))) # Base steps dengan range extreme
steps = base_steps + random.randint(-15, 35) # Add extreme random variation
steps = max(2, min(150, steps)) # Ensure reasonable range dengan variasi extreme
points = []
for i in range(steps + 1):
t = i / steps
# Add more realistic human imperfections
imperfection_x = random.uniform(-5, 5) # Increased micro-tremors
imperfection_y = random.uniform(-5, 5)
# Add natural overshoot and correction
if random.random() < 0.15: # 15% chance of overshoot
overshoot_x = random.uniform(-8, 8)
overshoot_y = random.uniform(-8, 8)
imperfection_x += overshoot_x
imperfection_y += overshoot_y
# More natural bezier curve with extreme variation and randomness
# Control point 1 with extreme natural variation
control1_factor_x = random.uniform(0.02, 1.0) # Extreme variation
control1_factor_y = random.uniform(0.02, 1.0) # Independent extreme variation
control1_x = start_pos[0] + (end_pos[0] - start_pos[0]) * control1_factor_x + random.randint(-150, 150)
control1_y = start_pos[1] + (end_pos[1] - start_pos[1]) * control1_factor_y + random.randint(-150, 150)
# Control point 2 with extreme natural variation
control2_factor_x = random.uniform(0.1, 1.5) # Extreme variation
control2_factor_y = random.uniform(0.1, 1.5) # Independent extreme variation
control2_x = start_pos[0] + (end_pos[0] - start_pos[0]) * control2_factor_x + random.randint(-130, 130)
control2_y = start_pos[1] + (end_pos[1] - start_pos[1]) * control2_factor_y + random.randint(-130, 130)
x = (1-t)**3 * start_pos[0] + 3*(1-t)**2*t * control1_x + 3*(1-t)*t**2 * control2_x + t**3 * end_pos[0]
y = (1-t)**3 * start_pos[1] + 3*(1-t)**2*t * control1_y + 3*(1-t)*t**2 * control2_y + t**3 * end_pos[1]
# Add imperfections
x += imperfection_x
y += imperfection_y
# Add occasional micro-corrections (like human adjusting)
if random.random() < 0.35: # 35% chance
x += random.uniform(-8, 8)
y += random.uniform(-8, 8)
# Add natural jitter
if random.random() < 0.60: # 60% chance of jitter
x += random.uniform(-3, 3)
y += random.uniform(-3, 3)
# Add occasional hesitation
if random.random() < 0.18: # 18% chance of hesitation
x += random.uniform(-12, 12)
y += random.uniform(-12, 12)
# Add natural tremor
if random.random() < 0.50: # 50% chance of tremor
x += random.uniform(-2.5, 2.5)
y += random.uniform(-2.5, 2.5)
# Add occasional overshoot
if random.random() < 0.15: # 15% chance of overshoot
x += random.uniform(-15, 15)
y += random.uniform(-15, 15)
# Add natural drift
if random.random() < 0.30: # 30% chance of drift
x += random.uniform(-5, 5)
y += random.uniform(-5, 5)
# Add natural fatigue
if random.random() < 0.08: # 8% chance of fatigue
x += random.uniform(-20, 20)
y += random.uniform(-20, 20)
# Add natural distraction
if random.random() < 0.05: # 5% chance of distraction
x += random.uniform(-25, 25)
y += random.uniform(-25, 25)
# Add natural muscle memory
if random.random() < 0.12: # 12% chance of muscle memory
x += random.uniform(-6, 6)
y += random.uniform(-6, 6)
# Add natural anticipation
if random.random() < 0.10: # 10% chance of anticipation
x += random.uniform(-8, 8)
y += random.uniform(-8, 8)
points.append((int(x), int(y)))
return points
def move_to_element(self, element, smooth=True):
try:
# Check if element is still valid
try:
# Test if element is still attached to DOM
element.is_displayed()
except Exception as e:
logging.warning(f"Element is stale, skipping mouse movement: {e}")
return False
if smooth:
try:
# Get element position safely
location = element.location_once_scrolled_into_view
size = element.size
center_x = location['x'] + size['width'] // 2
center_y = location['y'] + size['height'] // 2
# Get current mouse position (approximate)
current_pos = (random.randint(0, 1920), random.randint(0, 1080))
target_pos = (center_x, center_y)
# Generate movement path
movement_points = self.human_like_movement(current_pos, target_pos)
# Execute movement with error handling
for point in movement_points:
try:
self.driver.execute_script(f"""
try {{
var event = new MouseEvent('mousemove', {{
clientX: {point[0]},
clientY: {point[1]},
bubbles: true
}});
document.dispatchEvent(event);
}} catch(e) {{
// Ignore mouse movement errors
}}
""")
except Exception as e:
# Ignore individual mouse movement errors
pass
time.sleep(random.uniform(0.01, 0.05))
except Exception as e:
logging.warning(f"Smooth mouse movement failed: {e}")
# Move to element using ActionChains with error handling
try:
ActionChains(self.driver).move_to_element(element).perform()
return True
except Exception as e:
logging.warning(f"ActionChains mouse movement failed: {e}")
return False
except Exception as e:
logging.warning(f"Mouse movement failed: {e}")
return False
def random_mouse_movement(self, duration=1.0):
"""Enhanced random mouse movement with more natural human-like patterns"""
# Check if mouse movement is enabled in config
if not self.config.get('behavior.mouse_movement', True):
return True
try:
# Get viewport size safely
try:
viewport_size = self.driver.execute_script("return {width: window.innerWidth, height: window.innerHeight}")
except Exception as e:
# Fallback viewport size
viewport_size = {'width': 1920, 'height': 1080}
start_time = time.time()
current_pos = (random.randint(50, viewport_size['width']-50),
random.randint(50, viewport_size['height']-50))
# Use behavioral profiles from config
behavioral_profiles = self.config.get('behavior.behavioral_profiles', ['exploratory', 'focused', 'wandering', 'hesitant', 'reading', 'distracted'])
movement_pattern = random.choice(behavioral_profiles)
# Add natural micro-movements based on config
random_delays_enabled = self.config.get('behavior.random_delays', True)
micro_movement_chance = 0.3 if random_delays_enabled else 0.1 # Reduced chance if random delays disabled
while time.time() - start_time < duration:
try:
if movement_pattern == "exploratory":
# Large movements exploring the page
target_pos = (random.randint(100, viewport_size['width']-100),
random.randint(100, viewport_size['height']-100))
movement_speed = random.uniform(0.02, 0.08)
elif movement_pattern == "focused":
# Small movements around current area
target_pos = (current_pos[0] + random.randint(-100, 100),
current_pos[1] + random.randint(-100, 100))
target_pos = (max(50, min(viewport_size['width']-50, target_pos[0])),
max(50, min(viewport_size['height']-50, target_pos[1])))
movement_speed = random.uniform(0.01, 0.04)
elif movement_pattern == "wandering":
# Medium movements with pauses
target_pos = (random.randint(200, viewport_size['width']-200),
random.randint(200, viewport_size['height']-200))
movement_speed = random.uniform(0.03, 0.06)
else: # hesitant
# Small movements with frequent pauses
target_pos = (current_pos[0] + random.randint(-50, 50),
current_pos[1] + random.randint(-50, 50))
target_pos = (max(50, min(viewport_size['width']-50, target_pos[0])),
max(50, min(viewport_size['height']-50, target_pos[1])))
movement_speed = random.uniform(0.01, 0.03)
movement_points = self.human_like_movement(current_pos, target_pos)
for point in movement_points:
if time.time() - start_time >= duration:
break
try:
# Safe mouse movement with error handling
self.driver.execute_script(f"""
try {{
var event = new MouseEvent('mousemove', {{
clientX: {point[0]},
clientY: {point[1]},
bubbles: true
}});
document.dispatchEvent(event);