Mythus commited on
Commit
f3345f2
·
verified ·
1 Parent(s): 8ed0083

Update generator.py

Browse files
Files changed (1) hide show
  1. generator.py +8 -99
generator.py CHANGED
@@ -1,102 +1,11 @@
1
- import asyncio
2
- from playwright.async_api import async_playwright
3
- import logging
4
- import time
5
- from pathlib import Path
6
 
7
- # Setup the logging
8
- logging.basicConfig(level=logging.INFO, format='%(message)s')
9
- # Log a message at the start of your script
10
- logging.info('Docker Container Started')
11
 
12
- async def run():
13
- logging.info('Docker Container Started v2')
14
- async with async_playwright() as p:
15
- logging.info('Trying to launch Firefox...')
16
- browser = await p.firefox.launch(headless=True)
17
- logging.info('Firefox launched successfully.')
18
- page = await browser.new_page()
19
- logging.info('All fine until here')
20
- await page.goto('https://agogmail.com/', wait_until="domcontentloaded")
21
- logging.info('Entered ago-gmail')
22
- await page.wait_for_selector('.btn.btn-light.dropdown-toggle')
23
- await page.click('.btn.btn-light.dropdown-toggle')
24
 
25
- await page.wait_for_selector('a.changeMailbox[data-type="1"]')
26
- await page.click('a.changeMailbox[data-type="1"]')
27
- await asyncio.sleep(3)
28
-
29
- input_field = await page.query_selector('#active-mail')
30
- email = await input_field.get_attribute('value')
31
- logging.info("Active Mail Value: %s", email)
32
-
33
- form_page = await browser.new_page()
34
- await form_page.goto('https://altaregistrazione.net/')
35
-
36
- input_fields = await form_page.query_selector_all('input')
37
-
38
- await input_fields[0].fill(email)
39
- logging.info("Filled email: %s", email)
40
-
41
- await input_fields[1].fill(email)
42
- logging.info("Filled password")
43
-
44
- await input_fields[2].fill(email)
45
- logging.info("Filled confirm password")
46
-
47
- radio_buttons = await form_page.query_selector_all('input[type="radio"]')
48
- await radio_buttons[0].check()
49
- logging.info("Checked radio button")
50
-
51
- await form_page.wait_for_selector('.v-btn--block', state='visible')
52
-
53
- await form_page.click('.v-btn--block')
54
- logging.info("Continua Button Clicked")
55
-
56
- logging.info("Form-filled")
57
-
58
- await page.bring_to_front()
59
- await asyncio.sleep(8)
60
- await page.click('#refresh')
61
-
62
- await page.wait_for_function("document.querySelector('#message-list tr.font-bold')")
63
-
64
- all_mails = await page.query_selector_all('#message-list tr.font-bold')
65
-
66
- for email in all_mails:
67
- link = await email.query_selector('td:first-child a')
68
- sender_name = await link.inner_text()
69
-
70
- if "Altadefinizione" in sender_name:
71
- href = await link.get_attribute('href')
72
- full_url = f'https://agogmail.com/{href}'
73
- logging.info("Full URL: %s", full_url)
74
-
75
- mail_page = await browser.new_page()
76
- await mail_page.goto(full_url)
77
-
78
- await asyncio.sleep(5)
79
-
80
- verify_link = await mail_page.query_selector('.button.button-primary')
81
- verify_link_href = await verify_link.get_attribute('href')
82
-
83
- logging.info('Verification Link: %s', verify_link_href)
84
-
85
- await mail_page.goto(verify_link_href)
86
-
87
- await asyncio.sleep(5)
88
-
89
- cookies_list = await mail_page.context.cookies()
90
- for cookie in cookies_list:
91
- if cookie['name'] == 'ap_session':
92
- logging.info('ap_session cookie: %s', cookie['value'])
93
- # Write ap_session cookie to a file
94
- with open("session.txt", "w") as file:
95
- file.write(cookie['value'])
96
-
97
- await mail_page.close()
98
- break
99
-
100
- await browser.close()
101
-
102
- asyncio.run(run())
 
1
+ from flask import Flask
2
+ import generator # Import the generator script as a module
 
 
 
3
 
4
+ app = Flask(__name__)
 
 
 
5
 
6
+ @app.route('/api/cookie')
7
+ def cookie():
8
+ return {'ap_session': generator.ap_session}
 
 
 
 
 
 
 
 
 
9
 
10
+ if __name__ == '__main__':
11
+ app.run(host='0.0.0.0', port=8080)