File size: 3,930 Bytes
1458aea 6d9fbd5 adc4c52 6d9fbd5 214eb8d 1458aea cc6f741 1458aea 4d903e8 ebf42ec 4d903e8 1458aea bfd6c62 f60de42 bfd6c62 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea 6d9fbd5 1458aea adc2cb4 adc4c52 1458aea |
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 |
import asyncio
from playwright.async_api import async_playwright
import logging
import time
# Setup the logging
logging.basicConfig(level=logging.INFO, format='%(message)s')
# Log a message at the start of your script
logging.info('Docker Container Started')
async def run():
logging.info('Docker Container Started v2')
async with async_playwright() as p:
logging.info('Trying to launch Firefox...')
browser = await p.firefox.launch(headless=True)
logging.info('Firefox launched successfully.')
page = await browser.new_page()
logging.info('All fine until here')
await page.goto('https://agogmail.com/', wait_until="domcontentloaded")
logging.info('Entered ago-gmail')
await page.wait_for_selector('.btn.btn-light.dropdown-toggle')
await page.click('.btn.btn-light.dropdown-toggle')
await page.wait_for_selector('a.changeMailbox[data-type="1"]')
await page.click('a.changeMailbox[data-type="1"]')
await asyncio.sleep(3)
input_field = await page.query_selector('#active-mail')
email = await input_field.get_attribute('value')
logging.info("Active Mail Value: %s", email)
form_page = await browser.new_page()
await form_page.goto('https://altaregistrazione.net/')
input_fields = await form_page.query_selector_all('input')
await input_fields[0].fill(email)
logging.info("Filled email: %s", email)
await input_fields[1].fill(email)
logging.info("Filled password")
await input_fields[2].fill(email)
logging.info("Filled confirm password")
radio_buttons = await form_page.query_selector_all('input[type="radio"]')
await radio_buttons[0].check()
logging.info("Checked radio button")
await form_page.wait_for_selector('.v-btn--block', state='visible')
await form_page.click('.v-btn--block')
logging.info("Continua Button Clicked")
logging.info("Form-filled")
await page.bring_to_front()
await asyncio.sleep(8)
await page.click('#refresh')
await page.wait_for_function("document.querySelector('#message-list tr.font-bold')")
mail_field = await page.query_selector('#active-mail')
mail = await mail_field.get_attribute('value')
logging.info("Active Mail Value: %s", mail)
all_mails = await page.query_selector_all('#message-list tr.font-bold')
for email in all_mails:
link = await email.query_selector('td:first-child a')
sender_name = await link.inner_text()
if "Altadefinizione" in sender_name:
href = await link.get_attribute('href')
full_url = f'https://agogmail.com/{href}'
logging.info("Full URL: %s", full_url)
mail_page = await browser.new_page()
await mail_page.goto(full_url)
await asyncio.sleep(5)
verify_link = await mail_page.query_selector('.button.button-primary')
verify_link_href = await verify_link.get_attribute('href')
logging.info('Verification Link: %s', verify_link_href)
await mail_page.goto(verify_link_href)
await asyncio.sleep(5)
cookies_list = await mail_page.context.cookies()
for cookie in cookies_list:
if cookie['name'] == 'ap_session':
logging.info('ap_session cookie: %s', cookie['value'])
await mail_page.close()
break
await browser.close()
asyncio.run(run())
#while True:
# try:
# # your existing code here
# asyncio.run(run())
#except Exception as e:
# logging.error(f"An error occurred: {e}")
#finally:
# # sleep for 10 minutes
# time.sleep(5 * 60)
|