aeroswat Posted January 5, 2010 Share Posted January 5, 2010 Without having permission to access their data? This seems impossible to me without a very huge hassle but is there a way to do this? If so what would I need? Like let's say I wanted to go to a news site and read the weather. Would there be a way to do this without actually getting variables sent from them? Quote Link to comment https://forums.phpfreaks.com/topic/187258-is-there-a-way-to-read-information-on-a-website/ Share on other sites More sharing options...
Psycho Posted January 5, 2010 Share Posted January 5, 2010 Yes, it is very possible. Just use the PHP functions to read a file, but instead of a file path use the URL to the page. You will then need to create logic to extract the information you need. How that is done is dependant upon how the site constructs the page. But, if the site ever changes the format of their page your logic will break. Quote Link to comment https://forums.phpfreaks.com/topic/187258-is-there-a-way-to-read-information-on-a-website/#findComment-988864 Share on other sites More sharing options...
oni-kun Posted January 5, 2010 Share Posted January 5, 2010 Technically if you view their website, you are downloading their data for your own use (viewing), so unless the specific part of the website is copyrighted than it, atleast should be ethically acceptable to be able to. The only thing you can really do without them having an API is this: $sitename = "http://example.com/data.php?page=2"; $contents = file_get_contents($sitename); preg_match("/<title>([\w\s]*)</title>/i", $contents, $matches); //Match something on the page $webpage_title = $matches[1]; That for example, should download the page and dynamically pull the title tag (thus information) out of it. Just an example. Quote Link to comment https://forums.phpfreaks.com/topic/187258-is-there-a-way-to-read-information-on-a-website/#findComment-988865 Share on other sites More sharing options...
aeroswat Posted January 5, 2010 Author Share Posted January 5, 2010 Yes, it is very possible. Just use the PHP functions to read a file, but instead of a file path use the URL to the page. You will then need to create logic to extract the information you need. How that is done is dependant upon how the site constructs the page. But, if the site ever changes the format of their page your logic will break. Nice. This sounds very easy to do Just have to create unique logic for each individual page! Thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/187258-is-there-a-way-to-read-information-on-a-website/#findComment-988869 Share on other sites More sharing options...
Psycho Posted January 5, 2010 Share Posted January 5, 2010 Here's a tutorial: http://www.bradino.com/php/screen-scraping/ Quote Link to comment https://forums.phpfreaks.com/topic/187258-is-there-a-way-to-read-information-on-a-website/#findComment-988871 Share on other sites More sharing options...
aeroswat Posted January 5, 2010 Author Share Posted January 5, 2010 Here's a tutorial: http://www.bradino.com/php/screen-scraping/ Thankyou again! Looks very helpful. I'm going to have to try this once I'm done with this other project. If you have any experience with the FPDF class could ya help me on my other post? Quote Link to comment https://forums.phpfreaks.com/topic/187258-is-there-a-way-to-read-information-on-a-website/#findComment-988876 Share on other sites More sharing options...
ignace Posted January 5, 2010 Share Posted January 5, 2010 Before capturing content on their website and displaying on yours. You should contact the ones who you are scraping. Because if they have something like "All rights reserved" you'll be in some trouble when they find out your stole their content. I can be wrong here about something maybe futile but better safe than sorry I say Quote Link to comment https://forums.phpfreaks.com/topic/187258-is-there-a-way-to-read-information-on-a-website/#findComment-988954 Share on other sites More sharing options...
aeroswat Posted January 5, 2010 Author Share Posted January 5, 2010 Before capturing content on their website and displaying on yours. You should contact the ones who you are scraping. Because if they have something like "All rights reserved" you'll be in some trouble when they find out your stole their content. I can be wrong here about something maybe futile but better safe than sorry I say How about exactly that? a weather report? Say I wanted to say (Such and such news reports the weather as being 68 degrees today) Do you think that would be a big issue? It seems like I could just as easily manually type this in and show people. Doesn't seem like it would be a problem Quote Link to comment https://forums.phpfreaks.com/topic/187258-is-there-a-way-to-read-information-on-a-website/#findComment-988975 Share on other sites More sharing options...
Psycho Posted January 5, 2010 Share Posted January 5, 2010 Before capturing content on their website and displaying on yours. You should contact the ones who you are scraping. Because if they have something like "All rights reserved" you'll be in some trouble when they find out your stole their content. I can be wrong here about something maybe futile but better safe than sorry I say How about exactly that? a weather report? Say I wanted to say (Such and such news reports the weather as being 68 degrees today) Do you think that would be a big issue? It seems like I could just as easily manually type this in and show people. Doesn't seem like it would be a problem Are you doing your own weather forecasting? If you are using the content from another site you need to get permissions and, possibly, give credit. I have to believe there is some free service available to get current weather info. I'm sure you can find something with a little work. Quote Link to comment https://forums.phpfreaks.com/topic/187258-is-there-a-way-to-read-information-on-a-website/#findComment-989088 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.