-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp1.php
More file actions
50 lines (36 loc) · 1.32 KB
/
php1.php
File metadata and controls
50 lines (36 loc) · 1.32 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
<?php
$Url=$_POST['web'];
$html = file_get_contents($Url); //get the html returned from the spotify share url
$music_doc = new DOMDocument(); //creates a new document to place scraped data into
libxml_use_internal_errors(TRUE); //disable libxml errors
if(!empty($html)){ //check if any html is actually returned
$music_doc->loadHTML($html);
libxml_clear_errors(); //remove errors for unusable html
$music_xpath = new DOMXPath($music_doc);//creates new DOM path to search through
//get all the title tags from HTML doc
$music_row = $music_xpath->query('//title');
// store all pulled title tags and echo back
if($music_row->length > 0){
foreach($music_row as $row){
echo $row->nodeValue . "<br/>";
$text=$row->textContent;
}
}
}
$servername = 'uplifted-triode-168417:us-central:test';
$username = "test";
$password = "password";
$dbname = "test";
$conn = new mysqli($servername, $username, $password,$dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$sql = "INSERT INTO SpotifyInfo (Spotify1, Spotify2)
VALUES ('$Url', '$text')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
?>