View Full Version : Using PHP to collect Data
Gabriel14
04-04-2008, 11:37 AM
Hey all, i am back here with sorts of questions. Here i start. The situation happens that there is a:
1. Webpage with links inside. A whole load chunk of links. And once a link is clicked, it will bring you to a page where there is other data.
2. My aim is to use PHP to enter the links from the webpage and save the data selected as images and text into a folder of five. (Splitting the data collected into five folders)
3. I wonder if that was possible, hence i tried to ask around here. I know we can include the Map Axis thingy tag with HTML to locate it, but it seems that the data within different links look different.
I am willing to accept other possible hacks to complete this. But hopefully, we can do this with PHP and other hacks. (IDEs or smarty... etc are welcome as long as they help)
Thanks in advanced,
Gabriel :D
edit:
Realized that curl could be a possibility of an answer. Need more information!
Iszak
04-04-2008, 11:47 AM
Well my guess is to say seperator each url with commas then explode it use file_get_contents or something that puts it into a giant string or something then use preg_match to find all the images <img> as for the text no idea you could find <p> but the problem with that is not everyone uses <p> then obviously get all the images and etc into folders.
I think preg_split will also work.
Gabriel14
04-05-2008, 09:56 AM
Not really what i needed, but thanks anyway, Iszak. To make myself more clear, this was what i wanted:
1. A page carried lots of links to pages with lots of data within them. Basically mostly text and columns/boxes. Not really much images. My target is a specific area of text which carries all the data i need.
2. I want to use PHP to enter the links on the server, locate the data i need. (All the pages look almost the same but the text and information within them are different)
3. Collect the specific data, convert them to files and host them up on the server.
Inigoesdr
04-05-2008, 03:23 PM
Iszak is on the right track. From your description you basically want a PHP spider, which you can find examples of by searching. But the easiest way is using file_get_contents() to get the page, and preg_* to parse it.
Collect the specific data, convert them to files and host them up on the server.Thats making it awfully complicated. I wouldn't really do this - it adds unnecessary coding. Plus, I don't get what you mean by convert. Do you mean that the script with present processed data from raw data?
If your going down this route, I would recommend something simple: have one "master" page, and using query strings, depending on the query string, your script with pull data from another page in your website (which only contains that specific data) and place it on the "master" page. No converting of data for anything - just a PHP include().
Alternatively, you could place all the data in a database and just pull out what you need when using query strings.
Hope this helps.
Gabriel14
04-06-2008, 05:10 AM
I seem to have gotten your drift, Inigoesdr. I will try that out later. Well, BWiz, i don't really get you or perhaps you seem to have misunderstood me. (or that i didn't make my point clearer) For that, i apologize.
What i meant by number 3: "Collect the specific data, convert them to files and host them up on the server"
is that i wish to convert them to a specific file format, maybe let's say PDF. Or it can be some other format, maybe text into JPG? What i'm collecting from is text files on the server. On an important sidenote, i don't have administrator access to the page, nor any privileges to the server that holds the data that i'm going to collect. I need something that uses PHP to 'collect data from the client-side'
edit: I forgot to thank you guys for your help and i still need help here :) Thanks once again all!
Gabriel14
04-09-2008, 07:55 AM
Bumper Dee bump. I really hope someone else can provide insight into my question "http://www.codingforums.com/showpost.php?p=673790&postcount=6"
It sounds like what you want is a page scraper, at least for the first half of what you want
For the second half where you say you want to convert the text into pdf or jpg it would really depend on what you actually wanted to do for us to help you do it
I would google "php page scraper" and start reading up on that
http://www.google.com/search?q=php+page+scraper
Gabriel14
04-10-2008, 02:59 PM
Thanks very much Mr E, after much wait, i finally found my answer. That clearly goes to show that my belief in "an answer is always possible" is indeed true. Once again, thanks all for your insight :) I look forward more to learn from all of you guys and if there's any chance, i would help those i could in future.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.