tommyboy123x Posted May 25, 2007 Share Posted May 25, 2007 I've done some looking around but haven't found any kind of code that does just this. I need help with is how it will find the images / view the source of the web page. the only thing i can think of is saving the file to a directory in the server, opening it, and then <b>somehow</b> find where the images are. If it helps, all the images are .jpg, .jpeg, .gif, or .png just throwing out a few functions i might need would help a lot Long explanation: I'm trying to make a script that the user (mostly myself) types in a web address, the index page most likely, and the script grabs the logo of that page. Obviously it can't tell which image is the logo 100% of the time so we have it load the next page which displays the images it found (nothing is saved to the local server yet). The user selects which one is the logo and this is saved to the server in its own directory. Quote Link to comment https://forums.phpfreaks.com/topic/52992-solved-grabbing-a-logo-from-a-website/ Share on other sites More sharing options...
obsidian Posted May 25, 2007 Share Posted May 25, 2007 Do a Google search for "PHP screen scraping". Once you're able to determine the contents of a URL, just browse the text with a preg_match_all that pulls the src of all the img tags. From there, you can do your comparison without much effort. Quote Link to comment https://forums.phpfreaks.com/topic/52992-solved-grabbing-a-logo-from-a-website/#findComment-261784 Share on other sites More sharing options...
tommyboy123x Posted May 25, 2007 Author Share Posted May 25, 2007 cool thanks! Quote Link to comment https://forums.phpfreaks.com/topic/52992-solved-grabbing-a-logo-from-a-website/#findComment-261786 Share on other sites More sharing options...
tommyboy123x Posted May 25, 2007 Author Share Posted May 25, 2007 also a more step-by-step method http://www.web-development-blog.com/archives/parse-html-with-preg_match_all/ Quote Link to comment https://forums.phpfreaks.com/topic/52992-solved-grabbing-a-logo-from-a-website/#findComment-261799 Share on other sites More sharing options...
dj-kenpo Posted May 25, 2007 Share Posted May 25, 2007 keep in mind, this will be a problem if the logo is referenced in CSS and not on the real page, so you might want to grab the css files as well. all my sites uses divs where the logo goes, then the img is in the css. it's more flexible that way and less 1998 a la tables font tag garbage Quote Link to comment https://forums.phpfreaks.com/topic/52992-solved-grabbing-a-logo-from-a-website/#findComment-261803 Share on other sites More sharing options...
tommyboy123x Posted May 25, 2007 Author Share Posted May 25, 2007 most of the sites it'll be going through are really simple websites and the webmasters get confused with tables... i'd say at least 9/10 of them dont even have CSS files on the site nonetheless its a good thing to keep in mind, thanks Quote Link to comment https://forums.phpfreaks.com/topic/52992-solved-grabbing-a-logo-from-a-website/#findComment-261814 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.