| import requests |
| from bs4 import BeautifulSoup |
| import time |
| import re |
| import os |
| from datetime import datetime |
| import logging |
|
|
| logging.basicConfig(level=logging.INFO) |
| logger = logging.getLogger() |
|
|
| class AdShareTracker: |
| def __init__(self): |
| self.current_bid = None |
| self.bot_token = "8439342017:AAEmRrBp-AKzVK6cbRdHekDGSpbgi7aH5Nc" |
| self.chat_id = "2052085789" |
| self.session = requests.Session() |
| self.email = "s.an.t.o.smaic.a36.9@gmail.com" |
| self.password = "s.an.t.o.smaic.a36.9@gmail.com" |
| |
| |
| self.session.headers.update({ |
| 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36', |
| 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', |
| 'Accept-Language': 'en-US,en;q=0.5', |
| 'Accept-Encoding': 'gzip, deflate', |
| 'Connection': 'keep-alive', |
| }) |
| |
| def send_telegram(self, message): |
| """Send Telegram message""" |
| try: |
| url = f"https://api.telegram.org/bot{self.bot_token}/sendMessage" |
| data = { |
| "chat_id": self.chat_id, |
| "text": message, |
| "parse_mode": "HTML" |
| } |
| response = self.session.post(url, data=data, timeout=30) |
| if response.status_code == 200: |
| logger.info("π± Telegram sent") |
| return True |
| return False |
| except Exception as e: |
| logger.error(f"Telegram error: {e}") |
| return False |
| |
| def login_to_adshare(self): |
| """Login to AdShare and maintain session""" |
| try: |
| login_url = "https://adsha.re/login" |
| |
| |
| logger.info("π Getting login page...") |
| response = self.session.get(login_url, timeout=30) |
| |
| if response.status_code != 200: |
| logger.error(f"β Failed to get login page: {response.status_code}") |
| return False |
| |
| |
| login_data = { |
| 'email': self.email, |
| 'password': self.password, |
| |
| } |
| |
| |
| logger.info("π Attempting login...") |
| response = self.session.post(login_url, data=login_data, timeout=30) |
| |
| |
| test_url = "https://adsha.re/adverts/create" |
| response = self.session.get(test_url, timeout=30) |
| |
| if response.status_code == 200 and "adverts/create" in response.url: |
| logger.info("β
Login successful!") |
| return True |
| else: |
| logger.error("β Login failed - redirected or wrong page") |
| return False |
| |
| except Exception as e: |
| logger.error(f"β Login error: {e}") |
| return False |
| |
| def get_top_bid(self): |
| """Get current top bid after login""" |
| try: |
| create_url = "https://adsha.re/adverts/create" |
| |
| logger.info("π Fetching bid page...") |
| response = self.session.get(create_url, timeout=30) |
| |
| if response.status_code != 200: |
| logger.error(f"β Page fetch failed: {response.status_code}") |
| |
| if "login" in response.url: |
| logger.info("π Session expired, re-logging in...") |
| if self.login_to_adshare(): |
| response = self.session.get(create_url, timeout=30) |
| else: |
| return None |
| |
| soup = BeautifulSoup(response.content, 'html.parser') |
| |
| |
| for element in soup.find_all(string=re.compile(r'top bid is \d+ credits')): |
| match = re.search(r'top bid is (\d+) credits', element) |
| if match: |
| bid = int(match.group(1)) |
| logger.info(f"β
Current bid: {bid} credits") |
| return bid |
| |
| |
| labels = soup.find_all('div', class_='label') |
| for label in labels: |
| if 'top bid' in label.get_text(): |
| match = re.search(r'(\d+) credits', label.get_text()) |
| if match: |
| bid = int(match.group(1)) |
| logger.info(f"β
Found bid via label: {bid} credits") |
| return bid |
| |
| logger.warning("β Could not find bid information") |
| return None |
| |
| except Exception as e: |
| logger.error(f"β Error getting bid: {e}") |
| return None |
| |
| def start_tracking(self): |
| """Main tracking function""" |
| logger.info("π Starting AdShare Bid Tracker with Login...") |
| |
| |
| self.send_telegram("π€ <b>AdShare Bid Tracker Starting...</b>") |
| |
| |
| if not self.login_to_adshare(): |
| self.send_telegram("β <b>Login failed! Check credentials.</b>") |
| logger.error("β Cannot continue without login") |
| return |
| |
| self.send_telegram("β
<b>Login successful! Starting monitoring...</b>") |
| |
| |
| self.current_bid = self.get_top_bid() |
| if self.current_bid: |
| self.send_telegram(f"π― <b>Current Top Bid: {self.current_bid} credits</b>") |
| logger.info(f"π― Initial bid: {self.current_bid} credits") |
| else: |
| self.send_telegram("β <b>Could not get initial bid</b>") |
| logger.error("β Failed to get initial bid") |
| return |
| |
| |
| check_count = 0 |
| while True: |
| try: |
| time.sleep(300) |
| check_count += 1 |
| |
| logger.info(f"π Check #{check_count}...") |
| new_bid = self.get_top_bid() |
| |
| if new_bid: |
| if new_bid != self.current_bid: |
| logger.info(f"π¨ BID CHANGED: {self.current_bid} β {new_bid}") |
| |
| message = f"""π¨ <b>BID CHANGED!</b> |
| |
| π Before: {self.current_bid} credits |
| π After: {new_bid} credits |
| π Change: {new_bid - self.current_bid} credits |
| π Time: {datetime.now().strftime('%H:%M:%S')} |
| |
| π https://adsha.re/adverts/create""" |
| |
| if self.send_telegram(message): |
| self.current_bid = new_bid |
| |
| else: |
| logger.info(f"β
No change: {new_bid} credits") |
| |
| |
| if check_count % 12 == 0: |
| self.send_telegram(f"π <b>Status Update:</b> Still monitoring - {new_bid} credits after {check_count} checks") |
| |
| else: |
| logger.warning("β Failed to fetch bid - will retry") |
| |
| except KeyboardInterrupt: |
| logger.info("π Tracker stopped by user") |
| break |
| except Exception as e: |
| logger.error(f"β Loop error: {e}") |
| time.sleep(60) |
|
|
| if __name__ == "__main__": |
| tracker = AdShareTracker() |
| tracker.start_tracking() |