0
I have a code that searches a content inside an external site in the G1 case, it works perfectly but brings me with the page CSS so I can not customize to leave in the pattern of my site, searching found another that shows me the data without formatting giving me freedom to manipulated in the best possible way, but when I request an extensive content it does not open me giving me the following error.
Notice: Undefined offset: 2 in C:\xampp\htdocs\ruralrio\blog\2.php on line 15
my code and this
<?php
$url_base = "http://g1.globo.com/economia/noticia/2015/07/justica-paulista-suspende-multa-de-r-3-milhoes-ao-mcdonalds.html";
$texto = preg_replace("/((\r\n|\t)+|\s{2,})/", "",
file_get_contents($url_base));
preg_match('/<title>(.*)<\/title>/i', stripslashes($texto), $titulo);
preg_match('/<h1 class="entry-title">(.*)<\/h1>/i', stripslashes($texto), $titulomateria);
preg_match('/<h2>(.*)<\/h2>/i', stripslashes($texto), $titulomateria2);
preg_match('/<div class="materia-conteudo entry-content" id="materia-letra">(.*)<\/div>/i', stripslashes($texto), $titulomateria3);
echo strip_tags($titulo[1]) . "<br /><br />";
echo strip_tags($titulomateria[1]) . "<br /><br />";
echo strip_tags($titulomateria2[1]) . "<br /><br />";
echo strip_tags($titulomateria3[2]) . "<br /><br />";
?>
Good afternoon @guilhermenascimento tested here this way you passed me but generated another error and does not open the rest of the page
Parse error: syntax error, unexpected ''User-Agent: '' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in C:\xampp\htdocs\ruralrio\blog\2.php on line 6
– Cristiano Cardoso Silva
I continue with the same error :(, which may be in, because small text it picks up normally but large text no longer. already the other code that does not have as I customize displays everything without flaws and correctly but the one that I want to separate the contents already generates these errors
– Cristiano Cardoso Silva
I don’t know what’s going on here in my most ever the same mistake. kkk it returns to me like this
Economia - Justiça paulista suspende multa de R$ 3 milhões ao McDonald's

Justiça paulista suspende multa de R$ 3 milhões ao McDonald's

Recurso do Procon-SP foi recusado pelo Tribunal de Justiça de São Paulo.Entidade alega que rede veiculou comerciais abusivos do McLanche Feliz.


Notice: Undefined offset: 2 in C:\xampp\htdocs\ruralrio\blog\2.php on line 27
– Cristiano Cardoso Silva
Dude, I’m just using this code with nothing else on it. on the web server it does not generate the error and does not display the 4th item already in the location it shows that it has this error
– Cristiano Cardoso Silva
the page with only the texts [http://ruralrio.com.br/blog/2.php] and the page with all the tags and css [http://ruralrio.com.br/blog/index.g1economia2.php?url=http://G1.globo.com/economia/noticia/2015/07/justica-paulista-suspende-multa-de-r-3-milhoes-ao-Mcdonalds.html]
– Cristiano Cardoso Silva
I continued with the preg_match because when putting the DOM generated more errors because I do not know how to use the DOM correctly
– Cristiano Cardoso Silva
preg_match
is much more complex and not very recommended for this (at least most people agree). Which error generated in DOM?– Guilherme Nascimento
Warning: Domdocument::loadHTML(): Tag header invalid in Entity, line: 151 in C: xampp htdocs ruralrio blog 2.php on line 19 Warning: Domdocument::loadHTML(): ID frmBuscaScroll already defined in Entity, line: 237 in C: xampp htdocs ruralrio blog 2.php on line 19 Warning: Domdocument::loadHTML(): ID menu-2-noticias already defined in Entity, line: 677 in C: xampp htdocs ruralrio blog 2.php on line 19 Warning: Domdocument::loadHTML(): htmlParseEntityRef: no name in Entity, line: 4552 in C: xampp htdocs ruralrio blog 2.php on line 19
– Cristiano Cardoso Silva
Now cleaned the bugs no more build the page gets blank
– Cristiano Cardoso Silva
Let’s go continue this discussion in chat.
– Cristiano Cardoso Silva
Just what I needed Thank you very much I will study here how it works..
– Cristiano Cardoso Silva
@Cristianocardososilva study yes :) DOM is what there is kkk
– Guilherme Nascimento