![]() |
Fetch Favicon and page title
How could I make a script where a user types in an url to for example his youtube profile. When the user clicks "ok", it fetches the favicon and the page titles which it inserts into the database.
I'm pretty lost on how to fetch those favicons and page titles. :/ Hope someone can give a hint, or two! :D |
How about some pseudocode?
About step 2: I have almost no regular expression experience so I've always relied on really slow usage of the explode function when looking for tags. You'd explode on an open title tag, then explode again on the close title tag. You'd take the [0] index of the resulting array, I think. Good luck! |
Hmm, I found this function on the intrawebs actually to get the url of the favicon: (As I'm pretty bad with regular expressions as well)
PHP Code:
Should be pretty easy to make a remote upload script which could handle that. Edit: Made a rather simple remote upload script: PHP Code:
|
Won't it also be www.twitter.com.ico when you add the www.?
Also, are you sure you want the .com removed because that identifies the specific domain. There may be a twitter.net. |
True actually! Thanks Wildhoney. :)
It'll be a little harder when someone requests to upload a new twitter.com favicon, I should somehow check if there's already a: twitter.com.ico file in that dir. Instead of keep leeching Twitters bandwith each time someone wanna upload this ICO. I'm super new to working like this in PHP, so some help with how to do that would be awesome! Thanks. :) |
What is the script all about? I don't think I understand what it is you're doing.
You can check for the presence of the ICO file by doing the following: php Code:
|
It's for getting the favicon from a webpage (no matter where it's located, no matter which page there so www.youtube.com/d8Ud2 works as good as youtube.com), remote uploading this favicon to my own server so I won't leech their bandwith. If the file is 7 days < old, it's deletes the file and uploads a new one. Basically I got my script looking like this about an hour ago:
PHP Code:
PHP Code:
Something else is that if the user puts in: http://www.twitter.com it'll create: www.twitter.com.ico, however if he inputs http://twitter.com it'll create twitter.com.ico, how would I fix it so it'll make the http://twitter.com url to http://www.twitter.com, or just require the user to use www adresses as most websites supports this? This all is regular expressions, which I'm still in the proccess of learning, so I'd love some help on those topics. Hope that this was all understandable! Edit: It's all fixed due to awesome Bruja and Salethe on IRC! Here's the expression: http://slexy.org/view/s20e2YvBPt |
| All times are GMT. The time now is 06:27 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0