PDA

View Full Version : get text from any location, no selectors



NickNameDrive
10-22-2011, 02:50 AM
Hi All,

need to fetch some text from html, and there's no selectos

below example, text that needed to be fetched is in bold:

Be sure to use a descriptive title for your question that summarizes it. If your post includes code, wrap it around using the [CODE] tag7 for44 multi-line code, and the [ICODE] tag for inline code that's part of a sentence.


i'm new to in php, so if anyone decides to help, please do full script with end result output and comments are most welcome!

thanks in advance!

P.S. is it possible to grab few exact lines from external html without going end of file?

djr33
10-22-2011, 03:01 AM
First, if you want someone to do this for you ("full script with end result output and comments") that's a lot to ask for free-- post this in the paid work requests area if that's what you need.

Second, you'll need to give us more information. I don't see any identifying pattern in what you posted, so I have no idea how you would find it. (Even just doing it yourself by hand-- after that, we can figure out how to code it.) If you have any code you're working on post that as well.

NickNameDrive
10-22-2011, 03:43 AM
First, if you want someone to do this for you ("full script with end result output and comments") that's a lot to ask for free-- post this in the paid work requests area if that's what you need.

Second, you'll need to give us more information. I don't see any identifying pattern in what you posted, so I have no idea how you would find it. (Even just doing it yourself by hand-- after that, we can figure out how to code it.) If you have any code you're working on post that as well.

Paid job could be, but that's just not that big of a script, really just a minute with advanced knowledge of functions and syntax. Because, actually there's a selector there and that'd be the "space", but then how to count words from first word in black, then "space", then another word and "space", until you reach specific number of words.


As for P.S. question...

For example:


$text = fopen("http://localhost/test.html", "r");

while (!feof($text)) {

$output = fgets($text);

print $output;

}
fclose($text);

in this case you get the whole document with tags, but is there a way to get just line 70 to 90 and that's it, without having loading the whole html page. I don't even know how to request a line using PHP :confused:

found this little thing, but somehow it doesn't do


$file = 'sample.txt';
$f = fopen($file, r);
while ( $line = fgets($f, 1000) ) {
print $line;
}

and this, doen't work either


$file = $_GET['name'];
$f = fopen($file, r);
while ( $line = fgets($f, 1000) ) {
print $line;
}

traq
10-22-2011, 04:32 AM
Paid job could be, but that's just not that big of a script, really just a minute with advanced knowledge of functions and syntax.

telling people that their work -however trivial you may think it is- is not worth paying for is a sure-fire way to get no one to help you.

either be willing to put in some effort in figuring it out yourself, or hire someone - obviously, if it's a skill set you don't have, it's worth something.

----------


is there a way to get just line 70 to 90 and that's it, without having loading the whole html page
no. you can, however, ignore all the lines up to line 70, and all the lines after 90. is that what you want to do? will your target text always be lines 70-90? (from your example it would seem not.)

there's not much that can be done without knowing how you expect to find the text you want (how to identify it).

djr33
10-22-2011, 05:57 AM
One of the hardest things to do in programming is to make computers handle language. Here, first we need to determine exactly what the pattern is. Then it can be programmed. But a computer can't do things that a human can easily-- a computer needs very specific patterns that are reliable, or at the very least you'll have some errors some of the time.

A space character is something you can locate or use to split, but there are many of them and you will need to find a way to decide which one is correct.


Regardless of how "difficult" it is, the way is works here is pretty simple: if you need some help with what you're doing, we can point you in the right direction (for example by suggesting an idea or looking for an error in your code), but to actually do a complete project, that's where it becomes a paid project. If it really is "easy" then it won't be an expensive project, but it would still be beyond what we normally offer here. (Sometimes particularly generous member may help, but it's certainly not guaranteed.)