piznac Posted August 26, 2008 Share Posted August 26, 2008 Ok so I dont even know where to start. I need to take some text, like this paste: Ikariam Live the ancient world! You are here: World > Adatia[42:85] Info Attention: This area of the page is updated when you select a town! Actions Attention: This area of the page is updated when you select a town! Towns on Adatia * Guangzhou (i) o Name: Guangzhou o Town size: 17 o Player: DarthExile Send Message o Ally: - o Diplomacy o Transport goods o Pillage o Blockade harbor o Send out spy * Building ground * SG-1 o Name: SG-1 o Town size: 13 o Player: wj0912 Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Oceanside (u) o Name: Oceanside o Town size: 16 o Player: Gunner08 Send Message o Ally: - o Diplomacy o Send out spy * Building ground * Sphinx o Name: Sphinx o Town size: 20 o Player: Bean Send Message o Ally: WRL Send Message * beercity o Name: beercity o Town size: 21 o Player: Cyclops Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * 004 o Name: 004 o Town size: 8 o Player: rjrsson Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Hoodville 2 (u) o Name: Hoodville 2 o Town size: 17 o Player: Sniped2 Send Message o Ally: - o Diplomacy o Send out spy * Christopilis (i) o Name: Christopilis o Town size: 11 o Player: WRLChris Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * LOLbeer (i) o Name: LOLbeer o Town size: 13 o Player: redratfish Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * New Zlin o Name: New Zlin o Town size: 20 o Player: WRLPeer de Beer Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Building ground * hydro man o Name: hydro man o Town size: 17 o Player: terrinater Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * New Dystopia o Name: New Dystopia o Town size: 20 o Player: JangosAgony Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * king of saians (u) o Name: king of saians o Town size: 21 o Player: rogobodo Send Message o Ally: WRL Send Message o Diplomacy o Send out spy Special places on Adatia * Forest * Vines * Colossus Imprint Town navigation * Current town: [42:85] Sphinx o [42:82] Manticore o [43:84] Gryphon o [42:85] Sphinx o [43:85] Dune o [45:84] Osheanus * Previous Town * Next Town * Show World * Show Island * Show Town Resources of your Empire * Trade ships: 0(51) * Gold: 570,466 * Income: 234 Town´s resources * Population: 777 (1,878) * Action Points: 6 * Building material: 12,742 Storage capacity: 81,024 * Wine: 7,263 Storage capacity: 35,232 * Marble: 2,795 Storage capacity: 35,232 * Crystal Glass: 143 Storage capacity: 35,232 * Sulfur: 10,000 Storage capacity: 35,232 Overviews * Towns To Overview * Military To Overview * Research To Overview * Diplomacy To Overview © 2008 by Gameforge. All rights reserved. Rules T&Cs Imprint Other Options * Help * Ikariam PLUS (0) * Highscore * Options * Board * Logout * v.0.2.7 * 25.08.2008 23:38:52 First I need to pick out some data and remove the rest. I will highlight what I need: Ikariam Live the ancient world! You are here: World > Adatia[42:85] Info Attention: This area of the page is updated when you select a town! Actions Attention: This area of the page is updated when you select a town! Towns on Adatia * Guangzhou (i) o Name: Guangzhou o Town size: 17 o Player: DarthExile Send Message o Ally: - o Diplomacy o Transport goods o Pillage o Blockade harbor o Send out spy * Building ground * SG-1 o Name: SG-1 o Town size: 13 o Player: wj0912 Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Oceanside (u) o Name: Oceanside o Town size: 16 o Player: Gunner08 Send Message o Ally: - o Diplomacy o Send out spy * Building ground * Sphinx o Name: Sphinx o Town size: 20 o Player: Bean Send Message o Ally: WRL Send Message * beercity o Name: beercity o Town size: 21 o Player: Cyclops Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * 004 o Name: 004 o Town size: 8 o Player: rjrsson Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Hoodville 2 (u) o Name: Hoodville 2 o Town size: 17 o Player: Sniped2 Send Message o Ally: - o Diplomacy o Send out spy * Christopilis (i) o Name: Christopilis o Town size: 11 o Player: WRLChris Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * LOLbeer (i) o Name: LOLbeer o Town size: 13 o Player: redratfish Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * New Zlin o Name: New Zlin o Town size: 20 o Player: WRLPeer de Beer Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Building ground * hydro man o Name: hydro man o Town size: 17 o Player: terrinater Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * New Dystopia o Name: New Dystopia o Town size: 20 o Player: JangosAgony Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * king of saians (u) o Name: king of saians o Town size: 21 o Player: rogobodo Send Message o Ally: WRL Send Message o Diplomacy o Send out spy Special places on Adatia * Forest * Vines * Colossus Imprint Town navigation * Current town: [42:85] Sphinx o [42:82] Manticore o [43:84] Gryphon o [42:85] Sphinx o [43:85] Dune o [45:84] Osheanus * Previous Town * Next Town * Show World * Show Island * Show Town Resources of your Empire * Trade ships: 0(51) * Gold: 570,466 * Income: 234 Town´s resources * Population: 777 (1,878) * Action Points: 6 * Building material: 12,742 Storage capacity: 81,024 * Wine: 7,263 Storage capacity: 35,232 * Marble: 2,795 Storage capacity: 35,232 * Crystal Glass: 143 Storage capacity: 35,232 * Sulfur: 10,000 Storage capacity: 35,232 Overviews * Towns To Overview * Military To Overview * Research To Overview * Diplomacy To Overview © 2008 by Gameforge. All rights reserved. Rules T&Cs Imprint Other Options * Help * Ikariam PLUS (0) * Highscore * Options * Board * Logout * v.0.2.7 * 25.08.2008 23:38:52 Everything else I need to be gone. Now Im lost. I would like to use this data to send to a mysql db. That part I can handle, but getting this data in a usaable format,.. I seem to be lost. I need something like this: <town> <city> <name>$name</name> <townsize>$ts</townsize> <pname>$playername</pname> <ally>$ally</ally> </city> </town> Im not asking anyone to write it for me,. but some tips would great. Thanks! Quote Link to comment Share on other sites More sharing options...
effigy Posted August 27, 2008 Share Posted August 27, 2008 That's it as is? It has no line breaks? Quote Link to comment Share on other sites More sharing options...
piznac Posted August 27, 2008 Author Share Posted August 27, 2008 sadly yes thats how it comes out. Can't I search for "Name:", "Ally:","Town Size" & "Player" in a preg statement or something like that? But then how do I see whats after it,.. the results could be of various sizes for each of the categories. Town Size will likely remain a two digit int for quite some time, but thats it the rest alpha numeric of various sizes. Wait this is it after it is pasted in a text area,. is there a way to keep the orginal line breaks and would that make this easier? Here is an example of how it was before pasting it: Ikariam Live the ancient world! You are here: World > Adatia[42:85] Info Attention: This area of the page is updated when you select a town! Actions Attention: This area of the page is updated when you select a town! Towns on Adatia * Guangzhou (i) o Name: Guangzhou o Town size: 17 o Player: DarthExile Send Message o Ally: - o Diplomacy o Transport goods o Pillage o Blockade harbor o Send out spy * Building ground * SG-1 o Name: SG-1 o Town size: 13 o Player: wj0912 Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Oceanside (u) o Name: Oceanside o Town size: 16 o Player: Gunner08 Send Message o Ally: - o Diplomacy o Send out spy * Building ground * Sphinx o Name: Sphinx o Town size: 20 o Player: Bean Send Message o Ally: WRL Send Message * beercity o Name: beercity o Town size: 21 o Player: Cyclops Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * 004 o Name: 004 o Town size: 8 o Player: rjrsson Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Hoodville 2 (u) o Name: Hoodville 2 o Town size: 17 o Player: Sniped2 Send Message o Ally: - o Diplomacy o Send out spy * Christopilis (i) o Name: Christopilis o Town size: 11 o Player: WRLChris Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * LOLbeer (i) o Name: LOLbeer o Town size: 13 o Player: redratfish Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * New Zlin o Name: New Zlin o Town size: 20 o Player: WRLPeer de Beer Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Building ground * hydro man o Name: hydro man o Town size: 17 o Player: terrinater Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * New Dystopia o Name: New Dystopia o Town size: 20 o Player: JangosAgony Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * king of saians (u) o Name: king of saians o Town size: 21 o Player: rogobodo Send Message o Ally: WRL Send Message o Diplomacy o Send out spy Special places on Adatia * Forest * Vines * Colossus Imprint Town navigation * Current town: [42:85] Sphinx o [42:82] Manticore o [43:84] Gryphon o [42:85] Sphinx o [43:85] Dune o [45:84] Osheanus * Previous Town * Next Town * Show World * Show Island * Show Town Resources of your Empire * Trade ships: 0(51) * Gold: 570,466 * Income: 234 Town´s resources * Population: 777 (1,878) * Action Points: 6 * Building material: 12,742 Storage capacity: 81,024 * Wine: 7,263 Storage capacity: 35,232 * Marble: 2,795 Storage capacity: 35,232 * Crystal Glass: 143 Storage capacity: 35,232 * Sulfur: 10,000 Storage capacity: 35,232 Overviews * Towns To Overview * Military To Overview * Research To Overview * Diplomacy To Overview © 2008 by Gameforge. All rights reserved. Rules T&Cs Imprint Other Options * Help * Ikariam PLUS (0) * Highscore * Options * Board * Logout * v.0.2.7 * 25.08.2008 23:38:52 Quote Link to comment Share on other sites More sharing options...
effigy Posted August 27, 2008 Share Posted August 27, 2008 Here's a start: <pre> <?php $data = 'Ikariam Live the ancient world! You are here: World > Adatia[42:85] Info Attention: This area of the page is updated when you select a town! Actions Attention: This area of the page is updated when you select a town! Towns on Adatia * Guangzhou (i) o Name: Guangzhou o Town size: 17 o Player: DarthExile Send Message o Ally: - o Diplomacy o Transport goods o Pillage o Blockade harbor o Send out spy * Building ground * SG-1 o Name: SG-1 o Town size: 13 o Player: wj0912 Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Oceanside (u) o Name: Oceanside o Town size: 16 o Player: Gunner08 Send Message o Ally: - o Diplomacy o Send out spy * Building ground * Sphinx o Name: Sphinx o Town size: 20 o Player: Bean Send Message o Ally: WRL Send Message * beercity o Name: beercity o Town size: 21 o Player: Cyclops Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * 004 o Name: 004 o Town size: 8 o Player: rjrsson Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Hoodville 2 (u) o Name: Hoodville 2 o Town size: 17 o Player: Sniped2 Send Message o Ally: - o Diplomacy o Send out spy * Christopilis (i) o Name: Christopilis o Town size: 11 o Player: WRLChris Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * LOLbeer (i) o Name: LOLbeer o Town size: 13 o Player: redratfish Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * New Zlin o Name: New Zlin o Town size: 20 o Player: WRLPeer de Beer Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * Building ground * hydro man o Name: hydro man o Town size: 17 o Player: terrinater Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * New Dystopia o Name: New Dystopia o Town size: 20 o Player: JangosAgony Send Message o Ally: WRL Send Message o Diplomacy o Transport goods o Pillage o Send out spy * king of saians (u) o Name: king of saians o Town size: 21 o Player: rogobodo Send Message o Ally: WRL Send Message o Diplomacy o Send out spy Special places on Adatia * Forest * Vines * Colossus Imprint Town navigation * Current town: [42:85] Sphinx o [42:82] Manticore o [43:84] Gryphon o [42:85] Sphinx o [43:85] Dune o [45:84] Osheanus * Previous Town * Next Town * Show World * Show Island * Show Town Resources of your Empire * Trade ships: 0(51) * Gold: 570,466 * Income: 234 Town´s resources * Population: 777 (1,878) * Action Points: 6 * Building material: 12,742 Storage capacity: 81,024 * Wine: 7,263 Storage capacity: 35,232 * Marble: 2,795 Storage capacity: 35,232 * Crystal Glass: 143 Storage capacity: 35,232 * Sulfur: 10,000 Storage capacity: 35,232 Overviews * Towns To Overview * Military To Overview * Research To Overview * Diplomacy To Overview © 2008 by Gameforge. All rights reserved. Rules T&Cs Imprint Other Options * Help * Ikariam PLUS (0) * Highscore * Options * Board * Logout * v.0.2.7 * 25.08.2008 23:38:52'; preg_match_all('/\b(?:Name|Player|Ally|Town size):\s*\S+/', $data, $matches); print_r($matches); foreach ($matches[0] as $match) { list ($key, $value) = explode(': ', $match); echo "$key/$value<br>"; } ?> </pre> Quote Link to comment Share on other sites More sharing options...
piznac Posted August 27, 2008 Author Share Posted August 27, 2008 That is an awesome start,.. thanks a bunch bro. Now to try to figure out what you did. So you just matched on the keywords then that puts them in an array? Now how did you get the exact info after the keywords? I'm going to study this for a while,.. thanks again for taking the time! Quote Link to comment Share on other sites More sharing options...
effigy Posted August 27, 2008 Share Posted August 27, 2008 NODE EXPLANATION ---------------------------------------------------------------------- \b the boundary between a word char (\w) and something that is not a word char ---------------------------------------------------------------------- (?: group, but do not capture: ---------------------------------------------------------------------- Name 'Name' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- Player 'Player' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- Ally 'Ally' ---------------------------------------------------------------------- | OR ---------------------------------------------------------------------- Town size 'Town size' ---------------------------------------------------------------------- ) end of grouping ---------------------------------------------------------------------- : ':' ---------------------------------------------------------------------- \s* whitespace (\n, \r, \t, \f, and " ") (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- \S+ non-whitespace (all but \n, \r, \t, \f, and " ") (1 or more times (matching the most amount possible)) ---------------------------------------------------------------------- Quote Link to comment Share on other sites More sharing options...
piznac Posted August 27, 2008 Author Share Posted August 27, 2008 ahh ok I think I'm getting it. It searches after the exact word for everything (whitespace or not) before the next line break? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.