Page 1 of 1
Word Search
Posted: Sat Nov 22, 2003 7:39 pm
by Neo EnD
I have a project, and I'm not sure the best way to go about it.
I have a list of information. Example:
AAsking For Help (18:45)
AAsking for Trouble (25:15)
Aaaargh (9:16)
Aaargh (18:24)
Aabahran (3:7)
Aadellia (4:32)
AangelsBroughtMeHere (1:50)
Aapje (19:2)
Aapua (4:18)
Aarnio (7:22)
Eternal Abyss (20:36)
Eternal Abyss THC (24:16)
Eternal Agony (10:14)
Eternal Annihilator (35:47)
Eternal Anthrax (18:3)
Eternal Apathy (35:47)
AarGathul (21:6)
Aaraxis (12:26)
Aardvarkia (13:22)
Aardwolf (30:7)
Now I want to search the list, and when the word Eternal comes up, I want that whole line printed.
I'm pulling this information from a website, not from a database. Can anyone help?
Posted: Sat Nov 22, 2003 7:46 pm
by Neo EnD
Before that can happen though, I need it to scan a series of websites.
This is for an online game, Utopia.
Example:
http://a.swirve.com/kingdoms/nw-17.htm?rc=451009
I want to record into database: CTWarTimeW00T (30:17) 8,694,201 gc
Then as a seperate entry: The Utopians UA 4317 (43:17) 7,995,642 gc
And so on.
Is this possible?
Posted: Sat Nov 22, 2003 9:51 pm
by infolock
yeah, i play utopia myself so i kinda know where you are coming from.
anyways, you can do this by doing something like :
$filevar = implode('',file('
http://www.somesite.html'));
then you have all the content of that page in a single variable. you could then explode that variable into parts, or just search the contents for what you are looking for. or, a better way, would be to just dump the contents to a text document, open that file, read line by line searching for whatever string you need.
all this is possible, but it's gonna involve some research on your end. I'd suggest going to
http://www.php.net/file and reading up on the different file references they provide you with ( such as opening, reading, writing, and searching ). Overall, should just take a day or 2 of research and you should be good to go.
also, check on
http://www.hotscripts.com for HTML parsers or the like. i'm sure someone may have even already written a script to do this. hope that helps.
Posted: Sun Nov 23, 2003 2:08 pm
by Neo EnD
Thanks
A few people have, but you know how it is. No one develops the perfect script for your purpose. One script cans and shows current networths but does not provide accurate results, and the other scripts shows perfect results, but does not provice networths
research huh. awesome

Posted: Sun Nov 23, 2003 2:15 pm
by Neo EnD
awesome, I know how to gather the information now. But I'm still confused on how to search for something, and then when found, print that line. For example:
Line #22 : <TR><TH>4</TH><TD>The Futurama Planets (44:17)</TD><TD ALIGN=RIGHT>7,160,866 gc</TD></TR>
Searching that HTML code, then the word The pops up, I want to print the contents of Line #22.
Argh....please feel free to catch me on MSN if you guys can help. In the mean time, I'll keep digging.
MSN:
neosescape@hotmail.com
Posted: Sun Nov 23, 2003 3:12 pm
by Neo EnD
Code: Select all
$lines = file ('http://a.swirve.com/kingdoms/nw-17.htm?rc=451009');
From what I understand it as, this is our current problem. We need to be able to break the $lines array up. For example, if I echo $lines[33] with this line alone, i get this:
15Faithful Allegiance (13:17)5,554,841 gc
The contents of line #33. Awesome. But we need to be able to search those such lines, and sort them out, by whats inside of them.
http://www.eternalndeadly.com/test.php
Searching though that file, I want to be able to print only the lines that have the letters "UA" in them, next to each other (case sensative). Meaning, I should only want lines 20 and 50 printed.
So. How do we break the $lines array down further so we can search it for such letters?
Any help is appreciated!
Posted: Mon Nov 24, 2003 5:46 am
by Weirdan
[php_man]strpos[/php_man]
Code: Select all
$lines = file ('http://a.swirve.com/kingdoms/nw-17.htm?rc=451009');
foreach($lines as $line)
if(false!==strpos($line,'UA'))
echo $line."\n";
Posted: Tue Nov 25, 2003 11:23 am
by Neo EnD
Weirdan = Neo's HERO!!!!!!
Awesome. I'll be sure to let you guys see the finished product.