0

I know it is possible to get information (text) from another page.

For example, on the page at http://www.page.com/ is a div named news. How can I get the text from this div?

2
  • You need to clarify your intentions, do you with to be at www.one.com and collect data from www.two.com ? Commented Jun 14, 2010 at 20:54
  • Unless you own the other page, it isn't really nice to grab and parse the content of someone else's page and can create a lot of overhead and use up a lot of bandwidth even if you do. Commented Jun 14, 2010 at 20:54

2 Answers 2

4

Yes, that's what HTML Simple DOM is for amongst other options.

Example:

$html  = file_get_html('http://www.page.com/');
$mydiv = $html->find('div[id=news]', 0)->plaintext;
Sign up to request clarification or add additional context in comments.

3 Comments

+1 for using HTML simple dom parser which is similar to jQuery in terms of selectors :) however please don't forget to use clear() method when using multiple instances of HTML DOM (i.e. in iteration) as it's easy to reach the memory limit using this library :)
@migajek: thanks and sure this is just an example, OP is supposed to visit their site for more info about it.
I'm afraid that they do not state anywhere that is recommended to use "clear", that's why I've written it here ;)
0

Use an HTML parser.

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.