/** * Add product data * * @param Crawler $node */ private function addProduct(Crawler $node) { $product = new \stdClass(); /** @var Crawler $title */ $title = $node->filter('h3 a'); $product->title = trim($title->text()); $product->unit_price = $this->getPrice($node->filter('.pricePerUnit')); $productCrawler = $this->client->request('GET', $title->attr('href')); $product->size = $this->bytesToKb(strlen($this->client->getResponse()->getContent())); $product->description = ''; $description = $productCrawler->filterXPath('//h3[.="Description"]'); if ($description->count() > 0) { foreach ($description->siblings() as $sibling) { // product pages have different structures! if ($sibling->tagName == 'h3') { break; } if ($product->description != "") { $product->description .= "\n"; } // @TODO address formatting issues - breaks to new lines $product->description .= trim(preg_replace("/[^\\S\r\n]+/", " ", $sibling->nodeValue)); // remove excess whitespace but not new lines } } $this->total += $product->unit_price; // increment total $this->results[] = $product; }
public function testUserSeesPageTitle() { $client = new Client(); $crawler = $client->request('GET', 'http://localhost:8000/lists'); $this->assertEquals(200, $client->getResponse()->getStatus()); $this->assertCount(1, $crawler->filter('h1:contains("Lists")')); }
/** * simulate worldjournal ajax call to fetch content data */ public function actionTrypostdata() { $hostname = 'www.wjlife.com'; $optionVaules = ["relation" => "AND", "0" => ["relation" => "AND", "0" => ["key" => "wj_order_id"]]]; //all help wanted $currentURL = "/cls_category/03-ny-help-wanted/"; //temp page number $pno = 0; $queryObject = ["keyword" => "", "pagesize" => 40, "pno" => $pno, "optionVaules" => $optionVaules, "currentURL" => "http://" . $hostname . $currentURL, "currentCatId" => 327, "currentStateId" => 152]; //language: chinese simplified $wjlang = "zh-cn"; $requestUrl = "http://" . $hostname . "/wp-content/themes/wjlife/includes/classified-core.php?regions=state_ny&variant=" . $wjlang . "&t=" . time(); // echo "start...\n"; $client = new Client(); $crawler = $client->request("POST", $requestUrl, $queryObject, [], ['HTTP_X-Requested-With' => 'XMLHttpRequest', 'contentType' => 'application/x-www-form-urlencoded;charset=utf-8']); $rowHtml = $crawler->html(); // if you want to echo out with correct encoding, do `echo utf8_decode($rowHtml)` // echo utf8_decode($rowHtml); // echo "end...\n"; $subCrawler = new Crawler(); $subCrawler->addHtmlContent($rowHtml); $linkArray = $subCrawler->filter(".catDesc a")->each(function ($node, $index) { return $href = $node->attr('href'); }); print_r($linkArray); }
private function useProxyIfAvailable(Client $client) { if (defined('SS_OUTBOUND_PROXY') && defined('SS_OUTBOUND_PROXY_PORT')) { $guzzleClient = new GuzzleClient('', array('request.options' => array('proxy' => 'tcp://' . SS_OUTBOUND_PROXY . ':' . SS_OUTBOUND_PROXY_PORT))); $client->setClient($guzzleClient); } }
private function fetchDetails() { $url = 'https://www.twitter.com/' . $this->getAccountName(); $client = new Client(); $client->followRedirects(); $crawler = $client->request('GET', $url); /** * @var Response $response */ $response = $client->getResponse(); if ($response->getStatus() != '200') { $this->setIsNotFound(true); return false; } // -- if (stripos($response->getContent(), 'suspended')) { $this->setIsSuspended(true); return false; } // -- $post_times = $crawler->filter('#stream-items-id li ._timestamp')->each(function (Crawler $node) { return $node->attr('data-time'); }); rsort($post_times); $last_post_time = $post_times[0]; $hour_difference = round((time() - $last_post_time) / 60 / 60, 2); if ($hour_difference > 24) { // if last post was later than 24 hours $this->setDoesntHaveRecentPosts(true); } }
/** * Initializing the plugin's behavior * * @return void */ public function init() { $that = $this; $this->bot->onMessages('/^!php(doc)? (.*)/i', function (Event $event) use($that) { $request = $event->getRequest(); $matches = $event->getMatches(); $match = array_pop($matches); $client = new Client(); $crawler = $client->request('GET', sprintf('http://www.php.net/%s', str_replace('_', '-', $match))); if ($crawler->filter('.refnamediv h1.refname')->count() !== 0) { $function = $crawler->filter('.refnamediv h1.refname')->first()->text(); $description = $crawler->filter('.refnamediv span.dc-title')->first()->text(); $version = $crawler->filter('.refnamediv p.verinfo')->first()->text(); $synopsis = $crawler->filter('.methodsynopsis')->first()->text(); $synopsis = preg_replace('/\\s+/', ' ', $synopsis); $synopsis = preg_replace('/(\\r\\n|\\n|\\r)/m', ' ', $synopsis); $synopsis = trim($synopsis); $event->addResponse(Response::msg($request->getSource(), sprintf('%s - %s %s', $function, $description, $version))); $event->addResponse(Response::msg($request->getSource(), sprintf('Synopsis: %s', $synopsis))); } else { $suggestion = $crawler->filter('#quickref_functions li a b')->first()->text(); $event->addResponse(Response::msg($request->getSource(), sprintf('Could not find the requested PHP function. Did you mean: %s?', $suggestion))); } }); }
/** * @param int $id * * @throws SubjectNotFoundException * * @return JusticeRecord|false */ public function findById($id) { Assertion::integer($id); $crawler = $this->client->request('GET', sprintf(self::URL_SUBJECTS, $id)); $detailUrl = $this->extractDetailUrlFromCrawler($crawler); if (false === $detailUrl) { return false; } $people = []; $crawler = $this->client->request('GET', $detailUrl); $crawler->filter('.aunp-content .div-table')->each(function (Crawler $table) use(&$people) { $title = $table->filter('.vr-hlavicka')->text(); try { if ('jednatel: ' === $title) { $person = JusticeJednatelPersonParser::parseFromDomCrawler($table); $people[$person->getName()] = $person; } elseif ('Společník: ' === $title) { $person = JusticeSpolecnikPersonParser::parseFromDomCrawler($table); $people[$person->getName()] = $person; } } catch (\Exception $e) { } }); return new JusticeRecord($people); }
/** * Crawl single URL * @param string $url * @param int $depth */ protected function traverseSingle($url, $depth) { try { $client = new Client(); $client->followRedirects(); $crawler = $client->request('GET', $url); $statusCode = $client->getResponse()->getStatus(); $hash = $this->getPathFromUrl($url); $this->links[$hash]['status_code'] = $statusCode; if ($statusCode === 200) { $content_type = $client->getResponse()->getHeader('Content-Type'); if (strpos($content_type, 'text/html') !== false) { //traverse children in case the response in HTML document only $this->extractTitleInfo($crawler, $hash); $childLinks = array(); if (isset($this->links[$hash]['external_link']) === true && $this->links[$hash]['external_link'] === false) { $childLinks = $this->extractLinksInfo($crawler, $hash); } $this->links[$hash]['visited'] = true; $this->traverseChildren($childLinks, $depth - 1); } } } catch (CurlException $e) { $this->links[$url]['status_code'] = '404'; $this->links[$url]['error_code'] = $e->getCode(); $this->links[$url]['error_message'] = $e->getMessage(); } catch (\Exception $e) { $this->links[$url]['status_code'] = '404'; $this->links[$url]['error_code'] = $e->getCode(); $this->links[$url]['error_message'] = $e->getMessage(); } }
/** * Call orange portal and submit credentials * @return [type] [description] */ protected function loginToOrange() { $config = $this->getHelperSet()->get('config'); $this->outputMessage('Login to orange wifi ...'); // Forge form submit as there is no button or input $parameters = array('username' => $config['login'], 'password' => $config['pass'], 'isCgu' => 'true', 'code' => 0, 'lang' => 'fr', 'auth' => 1, 'restrictedCode' => '', 'restrictedProfile' => 0, 'restrictedRealm' => '', 'originForm' => 'true', 'tab' => '1'); try { $client = new Client(); $crawler = $client->request('POST', 'https://hautdebitmobile.orange.fr:8443/home/wassup', $parameters); } catch (\Exception $e) { $this->outputError('Connection error : ' . $e->getMessage(), true); exit(1); } // If login is a success, we should have follow the redirect to orange home page if ($client->getRequest()->getUri() == 'http://www.orange.fr') { $this->outputMessage('Login success !'); } else { $error_mssg = 'Login failed'; $div_error = $crawler->filterXPath("//div[@id='loginFormWassupErrorMessage']"); if ($div_error->count() == 1) { $error_mssg .= ' : ' . trim($div_error->text()); } $this->outputError($error_mssg); // Output raw reponse if (-vv) if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_VERBOSE) { echo $client->getResponse(); } return 1; } }
/** * * @api {get} /tarjeta/:id 1. Retorna la formación de una tarjeta Bip! según id * @apiGroup Tarjeta * @apiName Show * @apiParam {Number} id número identificador de tarjeta bip. * * @apiSuccess {String} code Código de respuesta de la llamada * @apiSuccess {String} num-tarjeta Número de la tarjeta. * @apiSuccess {String} estado Detalle del estado del contrato de la tarjeta. * @apiSuccess {String} saldo Saldo disponible en la tarjeta. * @apiSuccess {String} fecha-saldo Feccha de la última carga. * * @apiSuccessExample Success-Response: * HTTP/1.1 200 OK * { * "code": "John", * "num-tarjeta": "15470725", * "estado": "Contrato Activo", * "saldo": "$2.530", * "fecha-saldo": "10/09/2015 13:07", * } * @apiError (Error 404) 404 Número de tarjeta ingresado sin saldo asociado. * @apiErrorExample {json} Error-Response: * HTTP/1.1 404 Not Found * { * "code": 404, * "num-tarjeta": "111", * "message": "Esta tarjeta no tiene un saldo asociado" * } * @apiError (Error 400) 400 Número de tarjeta ingresado con formato incorrecto. * @apiErrorExample {json} Error-Response: * HTTP/1.1 404 Not Found * { * "code": 400, * "num-tarjeta": "1547AAA725", * "message": "El valor ingresado no es válido" * } */ public function show($id) { try { if (!is_numeric($id)) { $statusCode = 404; $response = ["code" => 404, "num-tarjeta" => $id, "message" => "El valor ingresado no es válido"]; return new JsonResponse($response, $statusCode); } $client = new Client(); $crawler = $client->request('POST', 'http://pocae.tstgo.cl/PortalCAE-WAR-MODULE/SesionPortalServlet?accion=6&NumDistribuidor=99&NomUsuario=usuInternet&NomHost=AFT&NomDominio=aft.cl&Trx=&RutUsuario=0&NumTarjeta=' . $id . '&bloqueable='); $nodeValues = $crawler->filter('td.verdanabold-ckc')->each(function ($node, $i) { return $node->text(); }); if (count($nodeValues) > 7) { $statusCode = 200; $response = ["code" => 200, "num-tarjeta" => $id, "estado" => $nodeValues[3], "saldo" => $nodeValues[5], "fecha-saldo" => $nodeValues[7]]; } else { $statusCode = 404; $response = ["code" => 404, "num-tarjeta" => $id, "message" => "Esta tarjeta no tiene un saldo asociado"]; } return new JsonResponse($response, $statusCode); } catch (Exception $e) { $statusCode = 500; $response = ["code" => 500, "num-tarjeta" => $id, "message" => "Error del servidor"]; return new JsonResponse(null, $statusCode); } }
function update() { $client = new Client(); $url = 'http://no.wikipedia.org/wiki/Norges_kommuner'; $crawler = $client->request('GET', $url); $entries = array(); $i = 0; $crawler->filter('div#bodyContent table.wikitable tr')->each(function ($node) use(&$i, &$entries) { if ($i > 0) { $ft = $node->filter('td')->eq(4)->html(); $ft = preg_replace('/<(.*)>/', '', $ft); $ft = preg_replace('/[^0-9]/', '', $ft); $item = array(); $item['knr'] = $node->filter('td')->eq(0)->text(); $item['kommune.navn'] = $node->filter('td')->eq(1)->text(); $item['kommune.admsenter'] = $node->filter('td')->eq(2)->text(); $item['kommune.fylke'] = $node->filter('td')->eq(3)->text(); // $item['kommune.folketall'] = urldecode($node->filter('td')->eq(4)->text()); $item['kommune.folketall'] = intval($ft, 10); $item['kommune.areal'] = $node->filter('td')->eq(5)->text(); $item['kommune.maalform'] = $node->filter('td')->eq(8)->text(); $item['kommune.iconurl'] = 'http:' . $node->filter('td')->eq(7)->filter('img')->attr('src'); // echo "Item " . $i . "\n"; // print_r($item); $entries[] = $item; } $i++; }); file_put_contents($this->cacheFile, json_encode($entries)); }
public function testAddRating_withGet_HasEmptyForm() { $client = new Client(); $response = $client->request('GET', 'http://localhost/workspace/cursoPHPUnit/gamebook/web/add-rating.php?game=1'); $this->assertCount(1, $response->filter('form')); $this->assertEquals("", $response->filter('form input[name=score]')->attr("value")); }
/** * return response code when crawling a given url * @param $url * @return mixed */ function crawl($url) { $client = new Client(); $client->request('GET', $url); $response_code = $client->getResponse()->getStatus(); return $response_code; }
function obtener_grupo($url) { $client = new Client(); $crawler = $client->request('GET', $url); $datos_grupo = obtener_datos_grupo($crawler); guardar_grupo($datos_grupo); }
/** * 現在の株価を取得する * * @param 整数値 $code 取得する株価コード * @return bool true 成功 */ public function getStockPrice($code) { try { $client = new Client(); $crawler = $client->request('GET', "http://stocks.finance.yahoo.co.jp/stocks/detail/?code={$code}.T"); // 前日終値、始値、高値、安値を取得する $array = $crawler->filter('dd')->each(function ($element) { $array = $element->filter('strong')->each(function ($element) { return $element->text(); }); // Debug::logPrintR($array); return count($array) > 0 ? $array[0] : null; }); // Debug::logPrintR($array); // $array の要素は以下の様になっている // [2] 前日終値 // [3] 始値 // [4] 高値 // [5] 安値 if (count($array) >= 6) { $this->beforeClosingPrice = $this->removeComma($array[2]); $this->openingPrice = $this->removeComma($array[3]); $this->highPrice = $this->removeComma($array[4]); $this->lowPrice = $this->removeComma($array[5]); } // 現在値を取得する $element = $crawler->filter('td.stoksPrice')->last(); $this->nowPrice = $this->removeComma($element->text()); } catch (exception $e) { // Debug::logPrintR($e); return false; } return true; }
protected function fetchTemplate() { $goutte = new Client(); $crawler = $goutte->request('GET', 'https://www.drupal.org/node/2373483'); $beta_evaluation = (string) $crawler->filter('div.codeblock code')->getNode(0)->nodeValue; return $beta_evaluation; }
public static function getHoje() { $nomes = ["Cantareira", "Guarapiranga", "Alto Cotia", "Alto Tietê", "Rio Claro", "Rio Grande"]; $client = new Client(); $crawler = $client->request('GET', 'http://www.apolo11.com/reservatorios.php?step=d'); $tables = $crawler->filter("font[face='arial']"); $data = $crawler->filter("font[face='verdana']"); $obj = new stdClass(); $obj->data = $data->eq(10)->text() . "/" . date('y'); $obj->niveis = array(); $tmp = array(); for ($i = 0; $i < 6; $i++) { $nivel = new stdClass(); $nivel->nome = $nomes[$i]; $nivel->hoje = $tables->eq($i * 9 + 16)->text(); $nivel->ontem = $tables->eq($i * 9 + 15)->text(); $nivel->chuva = preg_replace("/[^0-9,.]/", "", $tables->eq(5 - $i)->text()); $tmp[] = $nivel; } $obj->niveis[0] = $tmp[0]; $obj->niveis[1] = $tmp[3]; $obj->niveis[2] = $tmp[1]; $obj->niveis[3] = $tmp[2]; $obj->niveis[4] = $tmp[5]; $obj->niveis[5] = $tmp[4]; return $obj; }
public function __construct($url) { $client = new Client(); $crawler = $client->request('GET', $url); $this->content = $crawler->filterXPath("//div[@class='tekstas']"); $this->scrape(); }
/** * Extracts prices from HTML table. * * @param string $button Submit button text * @param array $location Region or county * @return array */ protected function extractPricesFromTable($button, array $location) { $prices = []; $crawler = $this->client->request('GET', 'http://www.ccs.cz/pages/phm2.php'); $form = $crawler->selectButton($button)->form(); $crawler = $this->client->submit($form, $location); $columnIterator = 0; $rowIterator = 0; $crawler->filter('table[class="dynamic"] td')->each(function (DomCrawler $node) use(&$prices, &$columnIterator, &$rowIterator) { switch ($columnIterator) { case 0: $prices[$rowIterator]['date'] = new \DateTime($node->text()); break; case 1: $prices[$rowIterator]['natural95'] = $node->text(); break; case 3: $prices[$rowIterator]['diesel'] = $node->text(); break; } $columnIterator = ++$columnIterator % 5; $rowIterator += $columnIterator == 0 ? 1 : 0; }); return $prices; }
/** * @param string $url * @return ProductList $list */ public function scrape($url) { $productList = new ProductList(); $client = new Client(); $crawler = $client->request('GET', $url); $crawler->filterXPath('//*[@class="productInfo"]/h3/a')->each(function ($node) use($productList, $client) { /** @var Crawler $node */ $product = new Product(); $link = $node->link(); $subPage = $client->click($link); $subPage->filter('.productTitleDescriptionContainer > h1')->first()->each(function ($node) use($product) { /** @var Crawler $node */ $product->title = trim($node->text()); }); $subPage->filter('.pricePerUnit')->each(function ($node) use($product) { /** @var Crawler $node */ $product->unitPrice = $node->text(); }); $product->size = sprintf("%.2f", strlen($subPage->html()) / 1024); $subPage->filter('.pricePerUnit')->each(function ($node) use($product) { /** @var Crawler $node */ preg_match("/[\\d\\.]+/", $node->text(), $price); $product->unitPrice = $price[0]; }); $subPage->filter('htmlcontent > div')->first()->each(function ($node) use($product) { /** @var Crawler $node */ $product->description = trim($node->text()); }); $productList->addProduct($product); }); return $productList; }
/** * Gets all shows and store them in json. */ public function updateShows() { $url = $this->builder->getAddictedShowsUrl(); printf("Trying to get shows from [%s].\n", $url); $crawler = $this->client->request('GET', $url); $showsLinkAndName = $crawler->filter('table.tabel90 > tr > td > h3 > a')->extract(['_text', 'href']); $showsSeasons = $crawler->filter('table.tabel90 > tr > td.newsDate')->extract(['_text']); if (count($showsLinkAndName) != count($showsSeasons)) { throw new \Exception("Inconsistencies detected while updating shows."); } printf("Found [%s] shows.\n", count($showsLinkAndName)); $shows = []; foreach ($showsLinkAndName as $n => $show) { $id = $this->extractShowId($show[1]); if ($this->nonEmptyShow($showsSeasons[$n])) { $name = Episode::sanitizeShowName($show[0]); // if multiple shows name reference the same id if (isset($this->mappedShowsNames()[$name])) { foreach ($this->mappedShowsNames()[$name] as $name) { $shows[$name] = $id; } } else { $shows[$name] = $id; } } } $this->io->saveShows($shows); }
/** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function index() { for ($i = 68; $i <= 78; $i++) { //$photos=Image::paginate(50); $client = new Client(); $baseURL = 'http://www.cutecatgifs.com/page'; $urlEndpoint = '/' . $i++; $crawler = $client->request('GET', $baseURL . $urlEndpoint); $photos = $crawler->filter('img.alignnone')->extract(array('src', 'alt')); foreach ($photos as $photo) { $url = $photo[0]; $title = $photo[1]; $extension = pathinfo($url, PATHINFO_EXTENSION); $filename = str_random(4) . '-' . str_slug($title) . '.' . $extension; // get file content from url and save in directory $file = file_get_contents($url); $save_file = file_put_contents('uploads/' . $filename, $file); // Create record in database $image = new \App\Image(); $image->name = $photo[1]; $image->url = $filename; $image->user_id = 1; $image->description = $photo[1]; $image->save(); } } }
/** * @param $url * @return Crawler */ function getDataURL($url) { $client = new Client(); $jsonURL = AlloSurfGetData::getJsonUrl($url); $crawler = $client->request('GET', $jsonURL); return $crawler; }
function devtips_get($url) { $tip = new DevTip(array("url" => $url)); $client = new Client(); $crawler = $client->request('GET', $url); $crawler->filter('div.dt-content')->each(function ($node) use(&$tip) { $html = trim($node->html()); // add line breaks $html = str_replace("><", ">\n<", $html); // remove aside $pos = strpos($html, "<aside"); if ($pos !== false) { $html = substr($html, 0, $pos); } // convert <p>'s to just line breaks $html = str_replace("<p>", "\n", $html); $html = str_replace("</p>", "\n", $html); $tip->set('content', $html); }); $crawler->filter('h3')->each(function ($node) use(&$tip) { $tip->set('title', $node->text()); }); $sources = $crawler->filter('div.dt-content *[src]')->extract(array('src')); $tip->set('assets', $sources); return $tip; }
public function scrape($url, $get_urls) { $this->comment('Scraping ' . $url); $client = new Client(); $crawler = $client->request('GET', $url); $title = ''; $tags = []; $movie_urls = []; $crawler->filter('h1.title')->each(function ($node) use(&$title) { $index = strpos($node->html(), '<'); $title = trim(substr($node->html(), 0, $index)); }); $crawler->filter('span[itemprop=genre]')->each(function ($node) use(&$tags) { array_push($tags, $node->text()); }); $crawler->filter('span[itemprop=name]')->each(function ($node) use(&$tags) { array_push($tags, trim($node->text())); }); $this->insertVideosAndTags($title, $tags); if ($get_urls) { $crawler->filter('a[href^="/m/"]')->each(function ($node) use(&$movie_urls) { array_push($movie_urls, 'http://www.rottentomatoes.com' . $node->attr('href')); }); } return $movie_urls; }
public function getCrawler() { if (!isset($this->crawler)) { $this->crawler = $this->client->request('GET', $this->getUri()); } return $this->crawler; }
public function testUserSeesWelcomeMessage() { $client = new Client(); $crawler = $client->request('GET', 'http://tinkoff'); $this->assertEquals(200, $client->getResponse()->getStatus()); $this->assertCount(1, $crawler->filter('h1:contains("Welcome to Tinkoff")')); }
protected static function fetchData(Client $client) { $page = $client->request('GET', 'http://www.movie.com.uy/teatro/'); $premieres = self::getPlays($page->filter('div#proximos_est')); $billboard = self::getPlays($page->filter('div#cartelera_prin')); return array_merge(SpiderHelper::getPosterData($page), ['billboard' => array_merge($premieres, $billboard)]); }
private function parseURLPDF() { $client = new Client(); $crawler = $client->request('GET', 'https://www.pcfactory.cl/ventabodega'); $href = $crawler->filter('a[class="main_link1"][href]')->first()->attr('href'); return 'https://www.pcfactory.cl/' . $href; }
/** * Obtém a lista de medicamentos do sistema da Anvisa e retorna um array * com os resultados. * * @param string $medicamento Nome de medicamento * @param string $empresa Nome da fabricante do medicamento * @param string $expediente Número do expediente da bula * * @throws \Exception Caso não for possível trazer os resultados * * @return \Collections\ArrayList Todas as bulas encontradas */ public static function buscarMedicamentos($medicamento = '', $empresa = '', $expediente = '') { if (empty($medicamento) && empty($empresa) && empty($expediente)) { throw new \InvalidArgumentException('Informe pelo menos um parâmetro para o método!'); } $Client = new Client(); $crawler = $Client->request('POST', 'http://www.anvisa.gov.br/datavisa/fila_bula/frmResultado.asp', ['hddLetra' => '', 'txtMedicamento' => $medicamento, 'txtEmpresa' => $empresa, 'txtNuExpediente' => $expediente, 'txtDataPublicacaoI' => '', 'txtDataPublicacaoF' => '', 'txtPageSize' => '1000', 'btnPesquisar' => '']); $Medicamentos = new ArrayList(); try { $trs = $crawler->filter('#tblResultado > tbody > tr'); if ($trs->first()->filter('td')->count() > 1) { $trs->each(function ($node) use(&$Medicamentos) { if (trim($node->filter('td')->eq(0)->text()) != 'Nenhuma bula na fila de análise') { $nomeMedicamento = trim($node->filter('td')->eq(0)->text()); $nomeEmpresa = trim($node->filter('td')->eq(1)->text()); $exp = trim($node->filter('td')->eq(2)->text()); $dataPub = trim($node->filter('td')->eq(3)->text()); $dadosBulaPaciente = self::stripJsFunction($node->filter('td')->eq(4)->filter('a')->attr('onclick')); $dadosBulaProfissional = self::stripJsFunction($node->filter('td')->eq(5)->filter('a')->attr('onclick')); $Bula = new Bula(); $Bula->setMedicamento($nomeMedicamento); $Bula->setEmpresa($nomeEmpresa); $Bula->setExpediente($exp); $Bula->setDataPublicacao($dataPub); $Bula->setBulaPaciente(new DadosBula($dadosBulaPaciente['transacao'], $dadosBulaPaciente['anexo'])); $Bula->setBulaProfissional(new DadosBula($dadosBulaProfissional['transacao'], $dadosBulaProfissional['anexo'])); $Medicamentos->add($Bula); } }); } } catch (\Exception $ex) { throw new Exception('Houve um erro ao obter os medicamentos do sistema da Anvisa!'); } return $Medicamentos; }