Skip to content

Commit 14e2fae

Browse files
committed
Checkin checkout php added
1 parent 250c226 commit 14e2fae

File tree

6 files changed

+63
-5
lines changed

6 files changed

+63
-5
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
scrapy.log
2+
3+
/logs/
4+
5+
logs/

checkin.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
$usersJson = file_get_contents("users.json");
4+
$userData = json_decode($usersJson, true);
5+
foreach($userData as $user) {
6+
echo "<pre>";
7+
$username = $user['username'];
8+
$password = $user['password'];
9+
// $url = $topic['question_url'];
10+
if (!empty($username) && !empty($password)) {
11+
$command = "scrapy crawl checkin -s LOG_FILE=logs/checkin.log -a checktype=checkin -a username=".$username." -a password=".$password."";
12+
echo "<pre>";
13+
echo $command;
14+
echo "<pre>";
15+
echo 'Crawling.....';
16+
shell_exec($command);
17+
sleep(2);
18+
}
19+
20+
}
21+
?>

checkout.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
$usersJson = file_get_contents("users.json");
4+
$userData = json_decode($usersJson, true);
5+
foreach($userData as $user) {
6+
echo "<pre>";
7+
$username = $user['username'];
8+
$password = $user['password'];
9+
// $url = $topic['question_url'];
10+
if (!empty($username) && !empty($password)) {
11+
$command = "scrapy crawl checkout -s LOG_FILE=logs/checkout.log -a checktype=checkout -a username=".$username." -a password=".$password."";
12+
echo "<pre>";
13+
echo $command;
14+
echo "<pre>";
15+
echo 'Crawling.....';
16+
shell_exec($command);
17+
sleep(2);
18+
}
19+
20+
}
21+
?>

oa_login/spiders/checkin.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def parse(self, response):
3939

4040

4141
def after_login(self, response):
42+
open_in_browser(response)
43+
4244
# token = response.xpath("//meta[@name='csrf-token']/@content").extract_first()
4345
# cookie = response.headers.getlist('Set-Cookie')[0].split(';')[0].split("=")[1]
4446
# # open_in_browser(response)
@@ -51,7 +53,7 @@ def after_login(self, response):
5153
# print response.url
5254

5355
if response.url != self.redirect_url:
54-
print 'Invalid username password'
56+
self.log 'Invalid username password'
5557
return
5658

5759
if self.checkin_checkout_type == 'checkin':
@@ -68,12 +70,12 @@ def after_login(self, response):
6870
)
6971

7072
def checkin(self, response):
71-
print 'If it is not redirected then check in successfull'
72-
# open_in_browser(response)
73+
self.log 'If it is not redirected then check in successfull'
74+
open_in_browser(response)
7375

7476
def checkout(self, response):
75-
print 'If it is not redirected then check out successfull'
76-
# open_in_browser(response)
77+
self.log 'If it is not redirected then check out successfull'
78+
open_in_browser(response)
7779

7880

7981

oa_login/spiders/checkin.pyc

17 Bytes
Binary file not shown.

users.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"username": "harris",
4+
"password": "harris"
5+
},
6+
{
7+
"username": "bemitaji",
8+
"password": "bemita123"
9+
}
10+
]

0 commit comments

Comments
 (0)