Ask Question Forum:
C
O
M
P
U
T
E
R
2
8
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Y-position of the mouse cursor
Attachment:===
How to extract specified data from webpaga in PHP

PHP program to extract one my favourite page and one specified data and saving& append it to a file , for example, the following webpage with its html code at line-11 in attached Example-1 with bold number of "119.000" that is what I want to extract and save. But it is really hard since only one "Unique" patten in whole webpage which is from line-6 to line-11. Be Reminded the example webpage has morethan 300 hundred lines more than the part of code I attached in the following example.
I have through those tutorial in PHP websit, final I try by error to test which PHP method is better and easier and came up with the following code
<?php
$pattern="Code of line6-line11 before "119.000" data being extracted";
$content = file_get_contents('http://www.myfavuirte.com');
preg_match(/$pattern/(?=.*)/, $content, $match);
echo $match[0] ; /* it should "code fo line-6...line11 before "119.000"
echo $match[1] ; /* it should be the data I want "119.000"*/
The PHP code above is not working and try by error for many days
Question-1, Should I use function explore() to make the whole pages into array first
such as $ARR1=explose(" ", $content) in order to avoid many line break and space(" ") parse error issue before
using preg_match to match the pattern with the webpage content
Question-2, I try to use explore to some code, it has parse error to those code when code having char
of <,> and "1234", and try use single quatation of ' instead of "" to set $pattern='code here ', but doesn't improve at all
For example , $pattern='<table width="100%" cellpadding="0" cellspacing="1">' instead of
$pattern="<table width="100%" cellpadding="0" cellspacing="1">"...Please advise it.
Question-3, Am I going to wrong direction to extract data from webpaga? In VBA this part may be easier since we can use document.innertext to extract text first and then use string extractor function to search/locate position of the data.
But VBA coudl not run on Linux server. Is there any easier way to extract my data from webpaga,
Question-4, Could provide some example code , let me to follow,
Please kindly advse and help
Br
Ducan
1-<table width="100%" cellpadding="0" cellspacing="1">
2- <tr valign="top">
3- <td rowspan="2" class="bg1 W1" width="50%">
4- <ul class="UL1">
5- <li class="LI1 font13_grey W1" style="padding-bottom: 16px">
6- ¿¿
7- </li>
8- </ul>
9- <ul class="UL1">
10- <li class="LI2 font28 C bold W1" style="font-size: 30px">
11- <span class="neg bold">119.000</span>
Okay, I trust you, and I switch from the crazy code like C/C++ and go to XML side.
This world should be really easy but complicated may be too bad at least more
interactive in this world .... Too many language and Too many system/platform/domain
But keep work hard ...
anyway thanks for reply
Duncan
Okay, I trust you, and I switch from the crazy code like C/C++ and go to XML side.
This world should be really easy but complicated may be too bad at least more
interactive in this world .... Too many language and Too many system/platform/domain
But keep work hard ...
anyway thanks for reply
Duncan
Okay, I trust you, and I switch from the crazy code like C/C++ and go to XML side.
This world should be really easy but complicated may be too bad at least more
interactive in this world .... Too many language and Too many system/platform/domain
But keep work hard ...
anyway thanks for reply
Duncan
Okay, I trust you, and I switch from the crazy code like C/C++ and go to XML side.
This world should be really easy but complicated may be too bad at least more
interactive in this world .... Too many language and Too many system/platform/domain
But keep work hard ...
anyway thanks for reply
Duncan
Okay, I trust you, and I switch from the crazy code like C/C++ and go to XML side.
This world should be really easy but complicated may be too bad at least more
interactive in this world .... Too many language and Too many system/platform/domain
But keep work hard ...
anyway thanks for reply
Duncan
Okay, I trust you, and I switch from the crazy code like C/C++ and go to XML side.
This world should be really easy but complicated may be too bad at least more
interactive in this world .... Too many language and Too many system/platform/domain
But keep work hard ...
anyway thanks for reply
Duncan
Okay, I trust you, and I switch from the crazy code like C/C++ and go to XML side.
This world should be really easy but complicated may be too bad at least more
interactive in this world .... Too many language and Too many system/platform/domain
But keep work hard ...
anyway thanks for reply
Duncan