Solved

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

Posted on 2009-07-16
2
281 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 500 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wordpress Plugin - Search From Action to Another Plugin file 13 49
tutorial for ebay api 3 35
Google Maps API and PHP 25 34
Curl & PHP Command Help 4 23
This article discusses how to create an extensible mechanism for linked drop downs.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

821 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