vendredi 31 juillet 2015

Parse Google image search parameters and save them in a db

I am trying to save google images in a db with various search parameters (i.e. TBS values). I need an idea how to parse google image search url so that I can save image sizes (i.e. tbs=isz:l for larger images, tbs=isz:m for medium images), image colors (i.e. tbs=ic:color for full color) and image type (i.e. tbs=itp:face for photo) etc.

for example, the following url search for “michael jackson” as a phrase, and limit results to 4 megapixel images or larger, color images, face images, and group the results by topic:

http://ift.tt/1DWymG1

and I would like to save all image info in my db.

I cannot figure out how to parse these search parameters dynamically so as to save in a db.

Here is my db schema:

CREATE TABLE IF NOT EXISTS `images` (
  `image_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `keyword_id` int(11) unsigned NOT NULL,
  `url` varchar(2083) NOT NULL,
  `size` varchar (50) NOT NULL,
  `color` varchar (50) NOT NULL,
  `type` varchar(50) NOT NULL,
  `created_at` datetime NOT NULL,
  PRIMARY KEY (`image_id`),
  KEY `keyword_id` (`keyword_id`)
) ENGINE=InnoDB; 

Aucun commentaire:

Enregistrer un commentaire