Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

how to extract text from a web page given start and end patterns

Posted on 2009-07-16
2
Medium Priority
?
319 Views
Last Modified: 2012-05-07
hi
i have some webpages , i need to run cron on them, so i need to extract a particular part of the webpage, i know there is a fixed text at start and end, using them, i need to extract the text between extremes,
can anyone tell me the code to use for it

thnx in advance
0
Comment
Question by:blaaze
2 Comments
 
LVL 10

Accepted Solution

by:
ollyatstithians earned 2000 total points
ID: 24867924
You can use file_get_contents() to capture the webpage to a variable then preg_match() to extract the portion you require.

http://uk2.php.net/manual/en/function.file-get-contents.php
http://uk2.php.net/manual/en/function.preg-match.php

Post some code if you need specifics.

Olly.
0
 
LVL 16

Expert Comment

by:alain34
ID: 24868072
Hello blaaze,

You can use file_get_contents with a url to extract the raw html http://uk.php.net/manual/en/function.file-get-contents.php
Use str_pos to identify the beginning and end your marker http://uk.php.net/manual/en/function.strpos.php
Use substr to extract the portion of text between your marker position http://uk.php.net/manual/en/function.substr.php

Regards,

alain34
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question