Upload WarOnline_Chat.py
Browse files- WarOnline_Chat.py +16 -12
WarOnline_Chat.py
CHANGED
@@ -5,8 +5,9 @@ from bs4 import BeautifulSoup
|
|
5 |
|
6 |
# Define the login URL and the thread URL
|
7 |
login_url = 'https://waronline.org/fora/index.php?login/login'
|
8 |
-
thread_url = 'https://waronline.org/fora/index.php?threads
|
9 |
-
|
|
|
10 |
|
11 |
# Define the login credentials
|
12 |
username = 'WarBot'
|
@@ -44,17 +45,20 @@ soup = BeautifulSoup(response.text, 'html.parser')
|
|
44 |
# Extract the _xfToken value from the hidden form field
|
45 |
xf_token = soup.find('input', {'name': '_xfToken'}).get('value')
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
'
|
52 |
-
'
|
53 |
-
'
|
54 |
-
'
|
55 |
-
'
|
|
|
|
|
56 |
}
|
57 |
-
|
|
|
58 |
|
59 |
# Check if the post was successful
|
60 |
if not response.ok:
|
|
|
5 |
|
6 |
# Define the login URL and the thread URL
|
7 |
login_url = 'https://waronline.org/fora/index.php?login/login'
|
8 |
+
thread_url = 'https://waronline.org/fora/index.php?threads/warbot-playground.17636/'
|
9 |
+
|
10 |
+
message = "Hello World"
|
11 |
|
12 |
# Define the login credentials
|
13 |
username = 'WarBot'
|
|
|
45 |
# Extract the _xfToken value from the hidden form field
|
46 |
xf_token = soup.find('input', {'name': '_xfToken'}).get('value')
|
47 |
|
48 |
+
post_url = "https://waronline.org/fora/index.php?threads/warbot-playground.17636/add-reply"
|
49 |
+
|
50 |
+
# Construct the message data for the POST request
|
51 |
+
message_data = {
|
52 |
+
'_xfToken': xf_token,
|
53 |
+
'message': message,
|
54 |
+
'attachment_hash': '',
|
55 |
+
'last_date': '',
|
56 |
+
'_xfRequestUri': post_url,
|
57 |
+
'_xfWithData': '1',
|
58 |
+
'_xfResponseType': 'json'
|
59 |
}
|
60 |
+
|
61 |
+
response = session.post(post_url, data=message_data)
|
62 |
|
63 |
# Check if the post was successful
|
64 |
if not response.ok:
|