0
I want to enter the site below, save all html in a variable, clear html and save the content I want in the database Mysql via PHP 7.
The site is: http://guildstats.eu/bosses?monsterName=&world=Ferobra&rook=0
At first I "saved the HTML of the page" in a variable, as code below:
$mundo = 'ferobra';
$url = 'http://guildstats.eu/bosses?monsterName=&world=' . $mundo . '&rook=0' . $mundo;
function curl_get_contents($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$pagina = curl_get_contents($url);
My difficulty now is cleaning the HTML, save this in arrays and then popular the database.
Can someone help me?
What would be clear HTML?
– Valdeir Psr
If you want to filter the
boss
, recommend this tutorial: https://medium.com/@valdeirpsr/extracting-information-from-a-site-with-php-bd3e3dec98e5– Valdeir Psr
It is that on this page there is a list (html)... I want to save its contents in the database. In the database it will have the same structure as the list. For example... if there is a column in the list called "name" and another "date of death", in the database you will have these two columns. I want to take the contents of the list that is in html and save in the database.
– lomiler
I managed to clean up a bit through php’s explode() function.
– lomiler
It is not recommended to use
explode
. The ideal is to use theDOMDocument
(explain how to use in the tutorial and in the answer). And after filtering everything (also explain), you can use that example.– Valdeir Psr