-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconstellations_virgo.php
55 lines (42 loc) · 1.63 KB
/
constellations_virgo.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
include_once 'simple_html_dom.php';
$mysqli = new mysqli('localhost', 'root', 'Tr!f0rce', 'zodiac');
/*if ($mysqli->query('DELETE FROM stars')) {
if ($mysqli->query('ALTER TABLE stars AUTO_INCREMENT = 1')) {
echo "<p>table stars reset</p>";
} else {
die("error resetting stars auto increment");
}
} else {
die("error deleting info in stars");
}*/
$zodiac = array("Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces");
$url = "http://en.wikipedia.org/wiki/List_of_stars_in_Virgo";
$html = file_get_html($url);
$data = $html->find('table[class=wikitable]');
if (isset($data[0])) {
//echo $data[0];
$counter = 0;
foreach ($data[0]->find('tr') as $row) {
if ($counter++ == 0) continue;
$name = $row->children(0)->plaintext;
$henry_draper = $row->children(3)->plaintext;
$hipparcos = $row->children(4)->plaintext;
$right_ascension = str_replace(' ', ' ', $row->children(5)->plaintext);
$declination = str_replace(' ', ' ',$row->children(6)->plaintext);
$magnitude = $row->children(7)->plaintext;
$distance = $row->children(9)->plaintext;
$spectral_class = $row->children(10)->plaintext;
echo $name;
echo "<br>";
if ($name == '') continue;
$mysqli->query("INSERT INTO stars SET name='$name', henry_draper='$henry_draper', hipparcos='$hipparcos', right_ascension='$right_ascension', declination='$declination', magnitude='$magnitude', distance='$distance', spectral_class='$spectral_class', constellation='virgo'");
if ($name == "PSR 1257+12") {
echo "name is empty string";
break 1;
}
}
} else {
echo "borked";
}
?>