phphtmlsimpledom

Use simple dom to get select by name


I'm trying to use simple dom to get an element by name

It's to crawl an old website and they only use name

<select name="id_items_1" required="">
    <option value="">Seleccione su talla</option>
    <option value="231085" data-talla="36" data-stock="3">36</option>
    <option value="231086" data-talla="37" data-stock="1">37</option>
</select>

I tried this but it returns null:

include('simple_html_dom.php');
$html = str_get_html($url);
$elem = $html->find('div[name=id_items_1]', 0);
var_dump($elem);

Is there any way to do this with simple dom?


Solution

  • you have to change to file_get_html and add http:// to url

    include('simple_html_dom.php'); 
    $url="http://platanitos.com/Platanitos-ZC-LUCY-161-Negro-49272";; 
    $html = file_get_html($url); 
    $elem = $html->find('select[name=id_items_1]', 0)->innertext; 
    var_dump($elem);