def test_normal(self): url = 'http://vinta.s3.amazonaws.com/godness_k.jpg' result = sbi.search_by(url=url) self.assertTrue(result) self.assertTrue(result.best_guess) self.assertTrue(len(result.images) > 0) self.assertEqual(len(result), len(result.images)) self.assertTrue(isinstance(result.to_dict(), dict))
def test_no_other_sizes(self): """ "No other sizes of this image found" in Google search result """ url = 'http://files.heelsfetishism.com/media/heels/2013/12/04/23823_5fbbba44bf474496a9b01dfebfb5d135.png.1440x0_q85_progressive.png' result = sbi.search_by(url=url) self.assertFalse(result) self.assertTrue(len(result.images) == 0)
relatedWords = dictionary.synonym(searchWord) relatedWord = relatedWords[0] # Word previously generated by bot prevWord = contents[0:index] # Get the image previously generated by the bot for media in mostRecent.entities.get("media", [{}]): #checks if there is any media-entity if media.get("type", None) == "photo": # checks if the entity is of the type "photo" imgUrl = media["media_url"] # save to file etc. result = sbi.search_by(url=imgUrl) fetcher = urllib2.build_opener() searchTerm = relatedWord # Download image using Bing Search bing_url = 'https://api.datamarket.azure.com/Bing/Search/Image' bing_api_key = 'b+otGGjd4HkdQTANFMjLpgaOEmTGDtR38z5JBlCwGPw' bing_auth = requests.auth.HTTPBasicAuth(bing_api_key, bing_api_key) bing_page_count = 1 bing_headers = { 'User-Agent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; FDM; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 1.1.4322)' }
relatedWords = dictionary.synonym(searchWord) relatedWord = relatedWords[0] # Word previously generated by bot prevWord = contents[0 : index] # Get the image previously generated by the bot for media in mostRecent.entities.get("media",[{}]): #checks if there is any media-entity if media.get("type",None) == "photo": # checks if the entity is of the type "photo" imgUrl = media["media_url"] # save to file etc. result = sbi.search_by(url=imgUrl) fetcher = urllib2.build_opener() searchTerm = relatedWord # Download image using Bing Search bing_url = 'https://api.datamarket.azure.com/Bing/Search/Image' bing_api_key = 'b+otGGjd4HkdQTANFMjLpgaOEmTGDtR38z5JBlCwGPw' bing_auth = requests.auth.HTTPBasicAuth(bing_api_key, bing_api_key) bing_page_count = 1 bing_headers = {'User-Agent':'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; FDM; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 1.1.4322)'} def getFirstImg(subject): payload = { 'Query':('\'' + subject + '\''),
def test_non_ascii_best_guess(self): url = 'http://vinta.s3.amazonaws.com/godness_k_2.jpg' result = sbi.search_by(url=url) self.assertTrue(result)
def test_non_ascii_url(self): url = 'https://vinta.s3.amazonaws.com/水原希子.jpg' result = sbi.search_by(url=url) self.assertTrue(result)