Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Passing variables to stored procedure 3 35
php email 2 26
object oriented programming comparison 5 52
How can I upload multiple images from a HTML form? 2 18
Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

914 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now