Solved

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

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
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.

759 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

23 Experts available now in Live!

Get 1:1 Help Now