Update generator.py
Browse files- generator.py +23 -37
generator.py
CHANGED
@@ -1,5 +1,9 @@
|
|
1 |
import asyncio
|
2 |
from playwright.async_api import async_playwright
|
|
|
|
|
|
|
|
|
3 |
|
4 |
async def run():
|
5 |
async with async_playwright() as p:
|
@@ -7,65 +11,53 @@ async def run():
|
|
7 |
page = await browser.new_page()
|
8 |
|
9 |
await page.goto('https://agogmail.com/')
|
10 |
-
|
11 |
await page.wait_for_selector('.btn.btn-light.dropdown-toggle')
|
12 |
await page.click('.btn.btn-light.dropdown-toggle')
|
13 |
|
14 |
-
# Then click the change mailbox button
|
15 |
await page.wait_for_selector('a.changeMailbox[data-type="1"]')
|
16 |
await page.click('a.changeMailbox[data-type="1"]')
|
17 |
await asyncio.sleep(3)
|
18 |
-
|
19 |
input_field = await page.query_selector('#active-mail')
|
20 |
email = await input_field.get_attribute('value')
|
21 |
-
|
22 |
|
23 |
-
# Go to the form page
|
24 |
form_page = await browser.new_page()
|
25 |
await form_page.goto('https://altaregistrazione.net/')
|
26 |
|
27 |
-
# Get all input fields
|
28 |
input_fields = await form_page.query_selector_all('input')
|
29 |
|
30 |
-
|
31 |
-
|
32 |
-
print("Filled email: ", email)
|
33 |
|
34 |
-
await input_fields[1].fill(email)
|
35 |
-
|
36 |
|
37 |
-
await input_fields[2].fill(email)
|
38 |
-
|
39 |
|
40 |
-
# Check the radio button
|
41 |
radio_buttons = await form_page.query_selector_all('input[type="radio"]')
|
42 |
-
await radio_buttons[0].check()
|
43 |
-
|
44 |
|
45 |
-
# Before clicking the button, make sure the page loads the dynamic content.
|
46 |
-
# we are waiting for the button to be visible.
|
47 |
await form_page.wait_for_selector('.v-btn--block', state='visible')
|
48 |
|
49 |
-
# Click the "Continua" button.
|
50 |
await form_page.click('.v-btn--block')
|
51 |
-
|
52 |
|
53 |
-
|
54 |
-
print("Form-filled\n")
|
55 |
|
56 |
await page.bring_to_front()
|
57 |
await asyncio.sleep(8)
|
58 |
-
await page.click('#refresh')
|
59 |
|
60 |
-
# wait for an email with class 'font-bold' to appear
|
61 |
await page.wait_for_function("document.querySelector('#message-list tr.font-bold')")
|
62 |
|
63 |
-
# Get active-mail value and print
|
64 |
mail_field = await page.query_selector('#active-mail')
|
65 |
mail = await mail_field.get_attribute('value')
|
66 |
-
|
67 |
|
68 |
-
# Get all unread mails with class 'font-bold'
|
69 |
all_mails = await page.query_selector_all('#message-list tr.font-bold')
|
70 |
|
71 |
for email in all_mails:
|
@@ -75,36 +67,30 @@ async def run():
|
|
75 |
if "Altadefinizione" in sender_name:
|
76 |
href = await link.get_attribute('href')
|
77 |
full_url = f'https://agogmail.com/{href}'
|
78 |
-
|
79 |
|
80 |
-
# Open new page and go to the full URL
|
81 |
mail_page = await browser.new_page()
|
82 |
await mail_page.goto(full_url)
|
83 |
|
84 |
-
# Wait for the page to load
|
85 |
await asyncio.sleep(5)
|
86 |
|
87 |
-
# Get the verification link
|
88 |
verify_link = await mail_page.query_selector('.button.button-primary')
|
89 |
verify_link_href = await verify_link.get_attribute('href')
|
90 |
|
91 |
-
|
92 |
|
93 |
-
# Open the verification link
|
94 |
await mail_page.goto(verify_link_href)
|
95 |
|
96 |
-
# Wait for the page to load
|
97 |
await asyncio.sleep(5)
|
98 |
|
99 |
-
# Get cookies
|
100 |
cookies_list = await mail_page.context.cookies()
|
101 |
for cookie in cookies_list:
|
102 |
if cookie['name'] == 'ap_session':
|
103 |
-
|
104 |
|
105 |
await mail_page.close()
|
106 |
|
107 |
-
break
|
108 |
|
109 |
await browser.close()
|
110 |
|
|
|
1 |
import asyncio
|
2 |
from playwright.async_api import async_playwright
|
3 |
+
import logging
|
4 |
+
|
5 |
+
# Setup the logging
|
6 |
+
logging.basicConfig(level=logging.INFO, format='%(message)s')
|
7 |
|
8 |
async def run():
|
9 |
async with async_playwright() as p:
|
|
|
11 |
page = await browser.new_page()
|
12 |
|
13 |
await page.goto('https://agogmail.com/')
|
14 |
+
|
15 |
await page.wait_for_selector('.btn.btn-light.dropdown-toggle')
|
16 |
await page.click('.btn.btn-light.dropdown-toggle')
|
17 |
|
|
|
18 |
await page.wait_for_selector('a.changeMailbox[data-type="1"]')
|
19 |
await page.click('a.changeMailbox[data-type="1"]')
|
20 |
await asyncio.sleep(3)
|
21 |
+
|
22 |
input_field = await page.query_selector('#active-mail')
|
23 |
email = await input_field.get_attribute('value')
|
24 |
+
logging.info("Active Mail Value: %s", email)
|
25 |
|
|
|
26 |
form_page = await browser.new_page()
|
27 |
await form_page.goto('https://altaregistrazione.net/')
|
28 |
|
|
|
29 |
input_fields = await form_page.query_selector_all('input')
|
30 |
|
31 |
+
await input_fields[0].fill(email)
|
32 |
+
logging.info("Filled email: %s", email)
|
|
|
33 |
|
34 |
+
await input_fields[1].fill(email)
|
35 |
+
logging.info("Filled password")
|
36 |
|
37 |
+
await input_fields[2].fill(email)
|
38 |
+
logging.info("Filled confirm password")
|
39 |
|
|
|
40 |
radio_buttons = await form_page.query_selector_all('input[type="radio"]')
|
41 |
+
await radio_buttons[0].check()
|
42 |
+
logging.info("Checked radio button")
|
43 |
|
|
|
|
|
44 |
await form_page.wait_for_selector('.v-btn--block', state='visible')
|
45 |
|
|
|
46 |
await form_page.click('.v-btn--block')
|
47 |
+
logging.info("Continua Button Clicked")
|
48 |
|
49 |
+
logging.info("Form-filled")
|
|
|
50 |
|
51 |
await page.bring_to_front()
|
52 |
await asyncio.sleep(8)
|
53 |
+
await page.click('#refresh')
|
54 |
|
|
|
55 |
await page.wait_for_function("document.querySelector('#message-list tr.font-bold')")
|
56 |
|
|
|
57 |
mail_field = await page.query_selector('#active-mail')
|
58 |
mail = await mail_field.get_attribute('value')
|
59 |
+
logging.info("Active Mail Value: %s", mail)
|
60 |
|
|
|
61 |
all_mails = await page.query_selector_all('#message-list tr.font-bold')
|
62 |
|
63 |
for email in all_mails:
|
|
|
67 |
if "Altadefinizione" in sender_name:
|
68 |
href = await link.get_attribute('href')
|
69 |
full_url = f'https://agogmail.com/{href}'
|
70 |
+
logging.info("Full URL: %s", full_url)
|
71 |
|
|
|
72 |
mail_page = await browser.new_page()
|
73 |
await mail_page.goto(full_url)
|
74 |
|
|
|
75 |
await asyncio.sleep(5)
|
76 |
|
|
|
77 |
verify_link = await mail_page.query_selector('.button.button-primary')
|
78 |
verify_link_href = await verify_link.get_attribute('href')
|
79 |
|
80 |
+
logging.info('Verification Link: %s', verify_link_href)
|
81 |
|
|
|
82 |
await mail_page.goto(verify_link_href)
|
83 |
|
|
|
84 |
await asyncio.sleep(5)
|
85 |
|
|
|
86 |
cookies_list = await mail_page.context.cookies()
|
87 |
for cookie in cookies_list:
|
88 |
if cookie['name'] == 'ap_session':
|
89 |
+
logging.info('ap_session cookie: %s', cookie['value'])
|
90 |
|
91 |
await mail_page.close()
|
92 |
|
93 |
+
break
|
94 |
|
95 |
await browser.close()
|
96 |
|