Repository navigation
Expand file tree
/
Copy pathfixed_automation_script.py
More file actions
1375 lines (1117 loc) · 54.5 KB
/
Copy pathfixed_automation_script.py
File metadata and controls
1375 lines (1117 loc) · 54.5 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
#!/usr/bin/env python3
"""
Fixed Multilogin Automation Script
==================================
Clean automation script without syntax errors
"""
import os
import random
import time
import logging
import requests
import sys
import json
from datetime import datetime
from urllib.parse import urlparse, urljoin
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains as Ac
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.webdriver.chrome.options import Options
# Global variables for Multilogin integration
PROFILE_ID = None
FOLDER_ID = None
AUTOMATION_CONFIG = {}
# Enhanced URL list for realistic browsing
ENHANCED_URLS = [
"https://google.com",
"https://youtube.com",
"https://amazon.com",
"https://ebay.com",
"https://reddit.com",
"https://twitter.com",
"https://facebook.com",
"https://instagram.com",
"https://linkedin.com",
"https://github.com"
]
class AdSenseAutoClick:
"""AdSense Auto Click functionality with smart probability"""
def __init__(self, driver, logger=None):
self.driver = driver
self.logger = logger or logging.getLogger(__name__)
# AdSense selectors
self.adsense_selectors = [
"ins.adsbygoogle",
"div[id*='google_ads']",
"div[id*='div-gpt-ad']",
"iframe[id*='google_ads']",
"div[class*='adsbygoogle']",
"div[id*='ad-']",
"div[class*='ad-']",
"div[class*='ads-']",
"div[class*='advertisement']",
"div[class*='banner']"
]
# Commercial keywords for intent detection
self.commercial_keywords = [
'buy', 'purchase', 'order', 'shop', 'cart', 'checkout',
'price', 'cost', 'sale', 'discount', 'offer', 'deal',
'product', 'service', 'subscription', 'membership',
'crypto', 'investment', 'trading', 'nft', 'blockchain'
]
def detect_adsense_ads(self):
"""Detect AdSense ads on current page"""
try:
ads_found = 0
ad_details = []
for selector in self.adsense_selectors:
elements = self.driver.find_elements(By.CSS_SELECTOR, selector)
for element in elements:
try:
if element.is_displayed():
ad_info = {
'selector': selector,
'text': element.text[:100] if element.text else '',
'location': element.location,
'size': element.size,
'element': element
}
ad_details.append(ad_info)
ads_found += 1
except:
continue
return {
'ads_detected': ads_found,
'details': ad_details
}
except Exception as e:
return {'error': str(e)}
def analyze_commercial_intent(self):
"""Analyze page content for commercial intent"""
try:
page_text = self.driver.find_element(By.TAG_NAME, "body").text.lower()
commercial_score = 0
for keyword in self.commercial_keywords:
if keyword in page_text:
commercial_score += 1
# Determine commercial category and click probability
if commercial_score > 10:
commercial_category = 'high'
click_probability = 0.05 # 5% chance
elif commercial_score > 5:
commercial_category = 'medium'
click_probability = 0.02 # 2% chance
else:
commercial_category = 'low'
click_probability = 0.01 # 1% chance
return {
'commercial_category': commercial_category,
'commercial_score': commercial_score,
'click_probability': click_probability
}
except Exception as e:
return {'error': str(e)}
def click_ad(self, ad_element):
"""Click on an ad element with multiple methods"""
try:
# Method 1: Direct click
try:
ad_element.click()
self.logger.info("Ad clicked successfully (direct method)")
return True
except:
pass
# Method 2: JavaScript click
try:
self.driver.execute_script("arguments[0].click();", ad_element)
self.logger.info("Ad clicked successfully (JavaScript method)")
return True
except:
pass
# Method 3: ActionChains click
try:
Ac(self.driver).move_to_element(ad_element).click().perform()
self.logger.info("Ad clicked successfully (ActionChains method)")
return True
except:
pass
self.logger.error("All click methods failed")
return False
except Exception as e:
self.logger.error(f"Click failed: {e}")
return False
def handle_ad_landing_page(self):
"""Handle ad landing page after click"""
try:
current_url = self.driver.current_url
# Check if we're on an ad landing page
ad_domains = ['googleadservices', 'doubleclick', 'googlesyndication', 'google-analytics']
is_ad_page = any(domain in current_url for domain in ad_domains)
if is_ad_page:
self.logger.info(f"Navigated to ad landing page: {current_url[:60]}...")
# Simulate time on ad page
time_on_page = random.uniform(5, 15)
self.logger.info(f"Spending {time_on_page:.1f} seconds on ad page")
time.sleep(time_on_page)
# Go back to original page
self.driver.back()
time.sleep(random.uniform(2, 4))
self.logger.info("Returned to original page")
return True
return False
except Exception as e:
self.logger.error(f"Error handling ad landing page: {e}")
return False
def auto_click_ads(self, max_ads=3, enable_clicking=True):
"""Main function to auto click AdSense ads"""
try:
self.logger.info("Starting AdSense Auto Click")
# Detect ads
adsense_results = self.detect_adsense_ads()
if "error" in adsense_results:
self.logger.error(f"AdSense detection failed: {adsense_results['error']}")
return {'status': 'detection_failed', 'error': adsense_results['error']}
ads = adsense_results.get('details', [])
if not ads:
self.logger.info("No AdSense ads found on this page")
return {'status': 'no_ads_found', 'ads_detected': 0}
self.logger.info(f"Found {len(ads)} AdSense ads")
# Analyze commercial intent
intent_results = self.analyze_commercial_intent()
if "error" in intent_results:
click_probability = 0.01 # Default 1% chance
commercial_category = 'unknown'
self.logger.warning(f"Intent analysis failed, using default probability: {click_probability*100:.1f}%")
else:
click_probability = intent_results.get('click_probability', 0.01)
commercial_category = intent_results.get('commercial_category', 'low')
self.logger.info(f"Commercial intent: {commercial_category} (score: {intent_results.get('commercial_score', 0)})")
self.logger.info(f"Click probability: {click_probability*100:.1f}%")
# Process ads
ads_processed = 0
ads_clicked = 0
for i, ad in enumerate(ads[:max_ads]):
try:
ads_processed += 1
self.logger.info(f"Processing ad {i+1}/{min(len(ads), max_ads)}...")
# Get ad element
ad_element = ad.get('element')
if not ad_element:
continue
# Scroll to ad
self.driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center'});", ad_element)
time.sleep(random.uniform(1, 3))
# Simulate hover
Ac(self.driver).move_to_element(ad_element).perform()
time.sleep(random.uniform(0.5, 1.5))
# Simulate reading ad content
ad_text = ad.get('text', '')[:50]
self.logger.info(f"Reading ad content: {ad_text}...")
time.sleep(random.uniform(2, 4))
# Decide whether to click
if enable_clicking and random.random() < click_probability:
self.logger.info(f"Deciding to click ad (probability: {click_probability*100:.1f}%)")
# Click the ad
if self.click_ad(ad_element):
ads_clicked += 1
# Handle landing page
self.handle_ad_landing_page()
else:
self.logger.info(f"Deciding not to click ad (realistic behavior)")
# Pause between ads
time.sleep(random.uniform(1, 2))
except Exception as ad_error:
self.logger.error(f"Error processing ad {i+1}: {ad_error}")
continue
# Summary
self.logger.info(f"AdSense auto click completed: {ads_clicked}/{ads_processed} ads clicked")
return {
'status': 'completed',
'ads_detected': len(ads),
'ads_processed': ads_processed,
'ads_clicked': ads_clicked,
'click_probability': click_probability,
'commercial_category': commercial_category,
'enable_clicking': enable_clicking
}
except Exception as e:
self.logger.error(f"AdSense auto click failed: {e}")
return {'status': 'failed', 'error': str(e)}
class CompleteMultiloginAutomation:
"""Complete automation bot with all features integrated"""
def __init__(self, driver, config=None):
self.driver = driver
self.config = config or self.get_default_config()
self.logger = self.setup_logging()
self.visited_domains = set()
self.session_start_time = time.time()
# Initialize behavior settings
self.behavior = self.config.get('behavior', {})
self.stealth = self.config.get('stealth', {})
self.targets = self.config.get('targets', {})
self.adsense_config = self.config.get('adsense', {})
self.personality = self.config.get('personality', {})
self.rpm_optimization = self.config.get('rpm_optimization', {})
# Setup websites
websites = self.config.get('websites', ENHANCED_URLS)
if self.behavior.get('random_order', False):
random.shuffle(websites)
if self.behavior.get('fraction_mode', 1.0) != 1.0:
part = int(len(websites) * self.behavior['fraction_mode'])
websites = websites[:part]
self.websites = websites
# Initialize AdSense Auto Click
self.adsense_clicker = AdSenseAutoClick(driver, self.logger)
# Personality and device type
self.user_personality = self.personality.get('type', 'explorer')
self.device_type = 'desktop'
# Session data
self.session_data = {
"start_time": datetime.now(),
"personality": self.user_personality,
"pages_visited": [],
"interactions": [],
"adsense_clicks": [],
"errors": []
}
self.logger.info(f'CompleteMultiloginAutomation initialized with {len(self.websites)} websites')
self.logger.info(f'Personality: {self.user_personality}')
self.logger.info(f'AdSense Auto Click: {self.adsense_config.get("enable_auto_click", False)}')
self.logger.info(f'RPM Optimization: {self.rpm_optimization.get("enabled", False)}')
def setup_logging(self):
"""Setup comprehensive logging"""
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setLevel(logging.INFO)
console_handler.setFormatter(logging.Formatter(
'%(asctime)s - %(levelname)s - %(message)s'))
# Create logs directory if it doesn't exist
os.makedirs('logs', exist_ok=True)
# File handler for persistent logging
file_handler = logging.FileHandler(f'logs/complete_automation_{datetime.now().strftime("%Y%m%d_%H%M%S")}.log')
file_handler.setLevel(logging.INFO)
file_handler.setFormatter(logging.Formatter(
'%(asctime)s - %(levelname)s - %(message)s'))
logger = logging.getLogger('multilogin_automation')
logger.setLevel(logging.INFO)
logger.addHandler(console_handler)
logger.addHandler(file_handler)
return logger
def get_default_config(self):
"""Get default automation configuration"""
return {
"websites": ENHANCED_URLS,
"behavior": {
"random_order": True,
"fraction_mode": 1.0,
"process_cookie_consent": True,
"pages_per_site": 3,
"scroll_range": [1, 5],
"sleep_range": [5, 15],
"timeout_seconds": 180
},
"stealth": {
"simulate_human_behavior": True,
"random_delays": True,
"mouse_movements": True,
"typing_simulation": True
},
"targets": {
"adsense_detection": True,
"ad_interaction": True,
"conversion_tracking": False
},
"adsense": {
"enable_auto_click": True,
"max_ads_per_page": 3,
"click_probability_override": None,
"min_time_on_ad_page": 5,
"max_time_on_ad_page": 15
},
"personality": {
"type": "explorer",
"attention_span": "medium",
"reading_speed": "medium",
"click_probability": 0.3
},
"rpm_optimization": {
"enabled": True,
"commercial_intent_detection": True,
"smart_ad_interaction": True,
"professional_behavior": True
}
}
def simulate_human_behavior(self):
"""Simulate realistic human browsing behavior"""
if not self.stealth.get('simulate_human_behavior', True):
return
# Random mouse movements
if self.stealth.get('mouse_movements', True):
self._simulate_mouse_movements()
# Random delays
if self.stealth.get('random_delays', True):
delay = random.uniform(1, 3)
time.sleep(delay)
def _simulate_mouse_movements(self):
"""Simulate realistic mouse movements"""
try:
# Get viewport size
viewport_width = self.driver.execute_script("return window.innerWidth;")
viewport_height = self.driver.execute_script("return window.innerHeight;")
# Generate random mouse movements
for _ in range(random.randint(2, 5)):
x = random.randint(0, viewport_width)
y = random.randint(0, viewport_height)
# Move mouse to random position
Ac(self.driver).move_by_offset(x, y).perform()
time.sleep(random.uniform(0.1, 0.5))
except Exception as e:
self.logger.debug(f"Mouse movement simulation failed: {e}")
def _simulate_natural_scrolling(self):
"""Simulate natural scrolling behavior"""
try:
# Get page height
total_height = self.driver.execute_script('return document.body.scrollHeight')
# Scroll in natural patterns
scroll_positions = [
total_height * 0.2,
total_height * 0.4,
total_height * 0.6,
total_height * 0.8
]
for position in scroll_positions:
self.driver.execute_script(f'window.scrollTo(0, {position});')
time.sleep(random.uniform(1, 3))
# Simulate reading behavior
self._simulate_reading_behavior()
except Exception as e:
self.logger.debug(f"Natural scrolling failed: {e}")
def _simulate_reading_behavior(self):
"""Simulate reading behavior"""
try:
# Find text elements
text_elements = self.driver.find_elements(By.TAG_NAME, "p")
if text_elements:
# Select random text element
element = random.choice(text_elements)
# Scroll to element
self.driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center'});", element)
time.sleep(random.uniform(2, 4))
# Simulate reading time based on text length
text_length = len(element.text)
reading_time = min(text_length / 200, 10) # 200 chars per second, max 10 seconds
time.sleep(reading_time)
except Exception as e:
self.logger.debug(f"Reading behavior simulation failed: {e}")
def _simulate_link_hovering(self):
"""Simulate link hovering behavior"""
try:
# Find clickable links
links = self.driver.find_elements(By.TAG_NAME, "a")
if links:
# Select random link
link = random.choice(links)
# Hover over link
Ac(self.driver).move_to_element(link).perform()
time.sleep(random.uniform(0.5, 1.5))
except Exception as e:
self.logger.debug(f"Link hovering simulation failed: {e}")
def _simulate_realistic_typing(self):
"""Simulate realistic typing behavior"""
try:
# Find input fields
inputs = self.driver.find_elements(By.TAG_NAME, "input")
if inputs:
# Select random input
input_field = random.choice(inputs)
# Focus on input
input_field.click()
time.sleep(random.uniform(0.5, 1))
# Sample texts
sample_texts = [
"hello world",
"test message",
"automation script",
"multilogin test"
]
text = random.choice(sample_texts)
# Type with realistic delays
for char in text:
input_field.send_keys(char)
time.sleep(random.uniform(0.05, 0.15))
except Exception as e:
self.logger.debug(f"Typing simulation failed: {e}")
def allow_cookies(self, site):
"""Handle cookie consent for various websites"""
if not self.behavior.get('process_cookie_consent', True):
return
self.logger.info(f'Processing cookie consent for {site}')
site_cookie_selectors = {
'twitter': (By.XPATH, "//button[contains(., 'Accept all cookies')]"),
'youtube': (By.XPATH, "//button[contains(., 'Accept all')]"),
'amazon': (By.ID, "sp-cc-accept"),
'google': (By.ID, "L2AGLb"),
'ebay': (By.ID, "gdpr-banner-accept"),
'aliexpress': (By.XPATH, "//button[contains(@class, 'btn-accept')]"),
'fiverr': (By.ID, "onetrust-accept-btn-handler"),
'yahoo': (By.XPATH, "//button[@name='agree' and @value='agree']"),
'twitch': (By.XPATH, "//button[@data-a-target='consent-banner-accept']"),
'instagram': (By.XPATH, "//button[contains(@class, '_a9--') and contains(@class, '_a9_1')]")
}
try:
# Try specific site selectors first
for site_key, (by, selector) in site_cookie_selectors.items():
if site_key in site:
if self._handle_cookie_button((by, selector), max_retries=3):
self.logger.info(f'Successfully handled cookies for {site_key}')
return
break
# Try Reddit-specific handling
if 'reddit' in site:
if self._handle_reddit_cookies():
self.logger.info("Successfully handled Reddit cookies")
return
# Fallback to generic cookie handling
if self._generic_allow_cookies():
self.logger.info("Successfully handled cookies using generic method")
return
self.logger.warning(f'Failed to handle cookies for {site}')
except Exception as e:
self.logger.error(f'Error handling cookies for {site}: {e}')
def _handle_cookie_button(self, locator, max_retries=3):
"""Handle cookie button clicking with retries"""
wait = WebDriverWait(self.driver, 10)
for attempt in range(max_retries):
try:
if wait.until(EC.presence_of_element_located(locator)):
button = wait.until(EC.element_to_be_clickable(locator))
# Scroll to button
self.driver.execute_script("arguments[0].scrollIntoView(true);", button)
time.sleep(1)
# Click button
try:
Ac(self.driver).move_to_element(button).click().perform()
except:
button.click()
time.sleep(2)
# Check if button disappeared
if wait.until(EC.invisibility_of_element_located(locator)):
return True
except Exception as e:
self.logger.debug(f'Cookie button attempt {attempt + 1} failed: {e}')
if attempt < max_retries - 1:
self.driver.refresh()
time.sleep(3)
return False
def _handle_reddit_cookies(self):
"""Handle Reddit's shadow DOM cookie banner"""
try:
# Wait for shadow host
shadow_host = WebDriverWait(self.driver, 20).until(
EC.presence_of_element_located((By.CSS_SELECTOR, "reddit-cookie-banner"))
)
# Get shadow root
shadow_root = self.driver.execute_script("return arguments[0].shadowRoot", shadow_host)
# Find accept button in shadow DOM
accept_button = shadow_root.find_element(By.CSS_SELECTOR, "#accept-all-cookies-button")
# Click accept button
self.driver.execute_script("arguments[0].click();", accept_button)
time.sleep(2)
return True
except Exception as e:
self.logger.debug(f'Reddit cookie handling failed: {e}')
return False
def _generic_allow_cookies(self):
"""Generic cookie acceptance using common text patterns"""
translations = [
"Accept", "allow all cookies", "accept all cookies", "accept cookies",
"alle akzeptieren", "alle cookies akzeptieren", "cookies akzeptieren",
"accepter tout", "accepter tous les cookies", "accepter les cookies",
"aceitar todos", "aceitar todos os cookies", "aceitar cookies",
"aceptar todo", "aceptar todas las cookies", "aceptar cookies",
"accetta tutto", "accetta tutti i cookie", "accetta i cookie",
"permitir tudo", "permitir todos os cookies", "permitir cookies",
"permitir todo", "permitir todas las cookies", "permitir cookies"
]
xpath_conditions = " or ".join([
f"contains(translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), '{translation.lower()}')"
for translation in translations
])
xpath = f"//button[{xpath_conditions}] | //div[@role='button'][{xpath_conditions}]"
try:
wait = WebDriverWait(self.driver, 10)
button = wait.until(EC.element_to_be_clickable((By.XPATH, xpath)))
# Scroll to button
self.driver.execute_script("arguments[0].scrollIntoView(true);", button)
time.sleep(1)
# Click button
try:
Ac(self.driver).move_to_element(button).click().perform()
except:
button.click()
time.sleep(2)
return True
except Exception as e:
self.logger.debug(f'Generic cookie handling failed: {e}')
return False
def run_personality_system(self):
"""Run personality system"""
try:
self.logger.info("Running Personality System")
# Personality-specific behaviors
behaviors = [
("scrolling", "Natural scrolling"),
("reading", "Reading behavior"),
("mouse", "Mouse interactions"),
("typing", "Typing simulation")
]
for behavior_type, description in behaviors:
try:
self.logger.info(f" {description}...")
if behavior_type == "scrolling":
self._simulate_natural_scrolling()
elif behavior_type == "reading":
self._simulate_reading_behavior()
elif behavior_type == "mouse":
self._simulate_mouse_movements()
self._simulate_link_hovering()
elif behavior_type == "typing":
self._simulate_realistic_typing()
# Record interaction
self.session_data["interactions"].append({
"type": behavior_type,
"personality": self.user_personality,
"timestamp": datetime.now().isoformat()
})
time.sleep(1)
except Exception as e:
self.logger.error(f" {behavior_type} failed: {e}")
except Exception as e:
self.logger.error(f"Personality system failed: {e}")
def run_navigation_system(self):
"""Run navigation system"""
try:
self.logger.info("Running Navigation System")
# Navigate to multiple pages (3-5 pages total)
pages_visited = 1 # Current page
max_pages = random.randint(3, 5)
self.logger.info(f"Target: {max_pages} pages total")
while pages_visited < max_pages:
# Try to navigate to next/previous page
new_url = self._navigate_previous_next()
if new_url:
self.logger.info(f"Navigating to page {pages_visited + 1}/{max_pages}")
self.driver.get(new_url)
time.sleep(random.uniform(2, 4))
# Record navigation
self.session_data["pages_visited"].append({
"url": new_url,
"timestamp": datetime.now().isoformat(),
"title": self.driver.title
})
# Simulate behavior on new page
self._simulate_natural_scrolling()
self._simulate_mouse_movements()
pages_visited += 1
else:
# Try random page navigation if prev/next not available
random_url = self._navigate_random_page()
if random_url:
self.logger.info(f"Navigating to random page {pages_visited + 1}/{max_pages}")
self.driver.get(random_url)
time.sleep(random.uniform(2, 4))
# Record navigation
self.session_data["pages_visited"].append({
"url": random_url,
"timestamp": datetime.now().isoformat(),
"title": self.driver.title
})
# Simulate behavior on new page
self._simulate_natural_scrolling()
self._simulate_mouse_movements()
pages_visited += 1
else:
self.logger.info(f"No more navigation links found, stopping at {pages_visited} pages")
break
self.logger.info(f"Visited {pages_visited} pages total")
except Exception as e:
self.logger.error(f"Navigation system failed: {e}")
def _navigate_previous_next(self):
"""Navigate to next/previous page"""
try:
# Look for navigation elements
nav_selectors = [
"a[rel='next']",
"a[rel='prev']",
".next",
".previous",
".pagination a",
"a:contains('Next')",
"a:contains('Previous')"
]
for selector in nav_selectors:
try:
elements = self.driver.find_elements(By.CSS_SELECTOR, selector)
for element in elements:
href = element.get_attribute("href")
if href and href != self.driver.current_url:
return href
except:
continue
return None
except Exception as e:
self.logger.debug(f"Navigation failed: {e}")
return None
def _navigate_random_page(self):
"""Navigate to random page on same domain"""
try:
# Find all links on current page
links = self.driver.find_elements(By.TAG_NAME, "a")
valid_links = []
current_domain = urlparse(self.driver.current_url).netloc
for link in links:
try:
href = link.get_attribute("href")
if href and current_domain in href and href != self.driver.current_url:
valid_links.append(href)
except:
continue
if valid_links:
return random.choice(valid_links)
return None
except Exception as e:
self.logger.debug(f"Random navigation failed: {e}")
return None
def run_adsense_auto_click(self):
"""Run AdSense auto click functionality"""
try:
self.logger.info("Running AdSense Auto Click")
# Check if AdSense auto click is enabled
if not self.adsense_config.get('enable_auto_click', True):
self.logger.info("AdSense auto click is disabled in config")
return {'status': 'disabled', 'reason': 'config_disabled'}
# Check if ad interaction is enabled
if not self.targets.get('ad_interaction', False):
self.logger.info("Ad interaction is disabled in targets")
return {'status': 'disabled', 'reason': 'targets_disabled'}
# Get configuration
max_ads = self.adsense_config.get('max_ads_per_page', 3)
enable_clicking = self.adsense_config.get('enable_auto_click', True)
# Run AdSense auto click
results = self.adsense_clicker.auto_click_ads(
max_ads=max_ads,
enable_clicking=enable_clicking
)
# Record results
self.session_data["adsense_clicks"].append({
"timestamp": datetime.now().isoformat(),
"results": results
})
# Record interaction
self.session_data["interactions"].append({
"type": "adsense_auto_click",
"results": results,
"timestamp": datetime.now().isoformat()
})
return results
except Exception as e:
self.logger.error(f"AdSense auto click failed: {e}")
return {'status': 'failed', 'error': str(e)}
def run_google_search(self):
"""Run Google search for maxgaming.biz.id"""
try:
self.logger.info("Starting Google search automation")
# Navigate to Google
self.logger.info("Navigating to Google...")
self.driver.get("https://www.google.com")
time.sleep(random.uniform(2, 4))
# Handle Google cookie consent
self.allow_cookies("https://www.google.com")
# Find search box with stealth approach
self.logger.info("Looking for search box...")
search_selectors = [
"input[name='q']",
"textarea[name='q']",
"input[title='Search']",
"input[aria-label='Search']"
]
search_box = None
for selector in search_selectors:
try:
search_box = WebDriverWait(self.driver, 10).until(
EC.presence_of_element_located((By.CSS_SELECTOR, selector))
)
self.logger.info(f"Found search box with selector: {selector}")
break
except:
continue
if not search_box:
self.logger.error("Could not find Google search box")
return False
# Simulate human-like typing
self.logger.info("Typing search query...")
search_query = "site:maxgaming.biz.id"
# Clear search box first
search_box.clear()
time.sleep(random.uniform(0.5, 1))
# Type with realistic delays
for char in search_query:
search_box.send_keys(char)
time.sleep(random.uniform(0.05, 0.15))
time.sleep(random.uniform(1, 2))
# Press Enter to search
self.logger.info("Submitting search...")
search_box.send_keys(Keys.RETURN)
time.sleep(random.uniform(3, 5))
# Wait for search results
self.logger.info("Waiting for search results...")
WebDriverWait(self.driver, 15).until(
EC.presence_of_element_located((By.CSS_SELECTOR, "div#search"))
)
# Look for maxgaming.biz.id results
self.logger.info("Looking for maxgaming.biz.id results...")
result_selectors = [
"a[href*='maxgaming.biz.id']",
"a[href*='maxgaming']",
"div.g a[href*='maxgaming']"
]
maxgaming_link = None
for selector in result_selectors:
try:
links = self.driver.find_elements(By.CSS_SELECTOR, selector)
for link in links:
href = link.get_attribute("href")
if href and "maxgaming.biz.id" in href:
maxgaming_link = link
self.logger.info(f"Found maxgaming link: {href}")
break
if maxgaming_link:
break
except:
continue
if not maxgaming_link:
self.logger.error("Could not find maxgaming.biz.id link in search results")
return False
# Simulate human-like clicking
self.logger.info("Clicking on maxgaming.biz.id link...")
# Scroll to link
self.driver.execute_script("arguments[0].scrollIntoView({behavior: 'smooth', block: 'center'});", maxgaming_link)
time.sleep(random.uniform(1, 2))
# Hover over link
Ac(self.driver).move_to_element(maxgaming_link).perform()
time.sleep(random.uniform(0.5, 1))
# Click the link
maxgaming_link.click()
time.sleep(random.uniform(3, 5))
# Verify we're on maxgaming.biz.id
current_url = self.driver.current_url
if "maxgaming.biz.id" in current_url:
self.logger.info(f"Successfully navigated to maxgaming.biz.id: {current_url}")
return True
else:
self.logger.warning(f"Not on maxgaming.biz.id, current URL: {current_url}")
return False
except Exception as e:
self.logger.error(f"Google search automation failed: {e}")