Jump to content

parsing with file_get_content


xymcrush17

Recommended Posts

Hello

Need a help

 

How to parse file_get_content into an array?

<?php

include_once('get_data.php');//simple_html_dom.php

$postdata = http_build_query(
    array(
        'id' => 'xxx',
        
    )
);
 
$opts = array('http' =>
    array(
        'method'  => 'POST',
        'header'  => 'Content-type: application/x-www-form-urlencoded',
        'content' => $postdata
    )
);
 
$context  = stream_context_create($opts);
 
$result = file_get_contents('http://localhost/test.php', false, $context);


I want only get a text that in attribute <div id="console"> YYYY </div> based on $result

 

text that i expect is YYYY

 

thank in advance

Edited by xymcrush17
Link to comment
Share on other sites

So what have you tried so far? Your code doesn't show any parsing attempts.

 

The task looks rather strange. You're posting data to your own scripts and scraping the response. How will the final application look like? Where does the data go? Why do you have to resort to scraping?

 

Your choice of tools is strange as well. Consider using cURL with a standard HTML parser like DOMDocument.

Edited by Jacques1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.