Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\Controller;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Symfony\Component\DomCrawler\Crawler;
- use Symfony\Component\HttpFoundation\Request;
- class DefaultController extends Controller
- {
- /**
- * @Route("/", name="homepàge")
- */
- public function pelisAction()
- {
- $wopelis = new Crawler(file_get_contents('http://www.wopelis.com/index'));
- $wopelis = $wopelis->filterXPath('//div[@data-model="peli"]')->each(function (Crawler $node) {
- return $node->extract('data-id');
- });
- $idPelis= array();
- foreach ($wopelis as $pelis) $idPelis[] = $pelis[0];
- return $this->render('default/index.html.twig', [
- 'pelis' => $idPelis
- ]);
- }
- /**
- * @Route("/{id}", name="pelis")
- */
- public function indexAction($id)
- {
- $wopelis = new Crawler(file_get_contents('http://www.wopelis.com/peli.php?id=' .$id));
- $links = new Crawler(file_get_contents('http://www.wopelis.com/venlaces.php?npl='.$id));
- $links = $links->filterXPath('//a[@class="enlace"]')->each(function (Crawler $node) {
- return $node->extract('onclick');
- });
- foreach ($links as $link) $linksClear[] = explode('\'',$link[0])[1];
- return $this->render('default/links.html.twig', [
- 'title' => $wopelis->filter('h1')->text(),
- 'plot' => $wopelis->filterXPath('//div[@class="info text"]')->text(),
- 'links' => isset($linksClear) ? $linksClear : null
- ]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement