-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdatescript.php
40 lines (33 loc) · 1.45 KB
/
updatescript.php
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
<?php
$conn = new mysqli('127.0.0.1', '', '', '');
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
datain();
function datain()
{
$content = htmlspecialchars(file_get_contents("https://www.104.com.tw/jobs/search/?keyword=vue"));
preg_match('/-(.*?)個工作機會/', $content, $vue);
$content = htmlspecialchars(file_get_contents("https://www.104.com.tw/jobs/search/?keyword=react"));
preg_match('/-(.*?)個工作機會/', $content, $react);
$content = htmlspecialchars(file_get_contents("https://www.104.com.tw/jobs/search/?keyword=angular"));
preg_match('/-(.*?)個工作機會/', $content, $angular);
global $conn;
$stmt = $conn->prepare('INSERT INTO `web`
(`vue`,
`react`,
`angular`)
SELECT ?,?,?
FROM DUAL
WHERE NOT EXISTS (SELECT *
FROM `web`
WHERE CURDATE() =
Date_format(`date`, "%Y/%m/%e")) ');
$stmt->bind_param("iii", $vue[1], $react[1], $angular[1]);
if (!$stmt->execute()) {
$err = "Execute failed: (" . $stmt->errno . ") " . $stmt->error;
}
$stmt->close();
$conn->close();
echo json_encode(mysqli_affected_rows($conn));
}