-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscraper.php
More file actions
70 lines (36 loc) · 1.56 KB
/
scraper.php
File metadata and controls
70 lines (36 loc) · 1.56 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
//var $city="";
if ($_SERVER["REQUEST_METHOD"] == "GET") {
$found="";
$cityName= $_GET['city'];
$cityName=str_replace(" ","",$cityName);//to remove space in City Name
if(!@file_get_contents("http://www.weather-forecast.com/locations/".$cityName."/forecasts/latest"))
{
echo http_response_code();
}
else{
$found="true";
$contents=file_get_contents("http://www.weather-forecast.com/locations/".$cityName."/forecasts/latest");
preg_match('/3 Day Weather Forecast Summary:<\/b><span class="read-more-small"><span class="read-more-content"> <span class="phrase">(.*?)</s', $contents, $matches);
echo $matches[1];
}
/// echo $contents;
//echo $matches[1];
/*
if(false !== (@file_get_contents("http://www.weather-forecast.com/locations/".$cityName."/forecasts/latest")))
{
$contents=file_get_contents("http://www.weather-forecast.com/locations/".$cityName."/forecasts/latest");
preg_match('/3 Day Weather Forecast Summary:<\/b><span class="read-more-small"><span class="read-more-content"> <span class="phrase">(.*?)</s', $contents, $matches);
//if(!empty($matches))
echo $matches[1];
}else
{
empty($matches);
echo "error";
//echo ($cityName);
//die(http_response_code(404));
}*/
/* /s ,at the end is for multiline , another one is /i, which probably for single line*/
//print_r($matches);
}
?>