Solved

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

Posted on 2009-07-16
2
299 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JSON decode 5 46
How can I split a variable 19 46
Considerations PHP using multiple locations 9 34
Ordering displaying data in a drop down 3 12
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…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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…

752 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