0

I have a code for read all inputs in a form.

The code works in my demo page an others, but not work in some pages. For the example issue:

facebook:

$url = 'https://www.facebook.com';

$html = file_get_html($url);
$post = $html->find('form[id=reg]'); //id for the register facebook page

print_r($post);

Print an empty array.

Functional example:

$url = 'http://www.monografias.com/usuario/registro';

$html = file_get_html($url);

$post = $html->find('form[name=myform]');
print_r($post);

Print a form content

3
  • Can you provide relevant html nodes? Commented Jan 27, 2016 at 18:34
  • I would love to get some control cases to look at specifically. That way we are all looking at the same sets of data. Commented Jan 27, 2016 at 18:36
  • What nodes? I only need take the form content. The functional example works. why not in facebook for example? Commented Jan 27, 2016 at 18:37

2 Answers 2

1

Facebook won't give you registration form directly, it will only respond with basic html, and the rest will be created with javascript. see for yourself

$url = 'https://www.facebook.com';
$html = file_get_html($url);
echo htmlspecialchars($html);

there is no form with "reg" ID in the html they send you.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, is this. I'ts imposible in this case?. When any web charge the code with javasrcipt?
I'm afraid the only way is to use a headless browser like phantomjs.org, save the evaluated result and parse it, but I think that's way too complex for a task at hand.
1

simple_html_dom.php contains a line limiting the max file size it will parse:

define('MAX_FILE_SIZE', 600000);

For files larger than this size, file_get_html() will just return false.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.