Open barbar-binks opened 2 years ago
It's still working for me.
Update it to latest and try. It's working now
Update it to latest and try. It's working now
I will do that, thank you very much.
Update it to latest and try. It's working now
Updated and the image array is still showing up empty, is there any way of checking the response from Google? maybe there is something i need to change on my side.
i checked again and it's working fine for me. Can you show me your code?
i checked again and it's working fine for me. Can you show me your code?
yes, a simple search as the example shows as empty:
public function handle() { $keyword = $this->argument("keyword"); $images = GoogleImageGrabber::grab($keyword); print_r($images); return 0; }
i checked again and it's working fine for me. Can you show me your code?
yes, a simple search as the example shows as empty:
I am using Laravel 9
Your code is working fine for me i think you are not passing the keywords correctly. Try below code code.
public function handle()
{
$keyword = $this->argument("keyword");
if (!empty($keyword)) {
return \Buchin\GoogleImageGrabber\GoogleImageGrabber::grab($keyword);
}
return false;
}
Your code is working fine for me i think you are not passing the keywords correctly. Try below code code.
public function handle() { $keyword = $this->argument("keyword"); if (!empty($keyword)) { return \Buchin\GoogleImageGrabber\GoogleImageGrabber::grab($keyword); } return false; }
thank you, i changed it up a bit because this test is a laravel command. I printed the result using this code and using the argument "apple":
` public function handle() { $keyword = $this->argument("keyword"); if (!empty($keyword)) { print_r("your keyword was " . $keyword . "\n"); print_r(\Buchin\GoogleImageGrabber\GoogleImageGrabber::grab($keyword)); return true; } print_r("your keyword was: " . $keyword . "\n"); return false; }
`
got this response:
your keyword was apple Array ( )
Your code is working fine for me i think you are not passing the keywords correctly. Try below code code.
public function handle() { $keyword = $this->argument("keyword"); if (!empty($keyword)) { return \Buchin\GoogleImageGrabber\GoogleImageGrabber::grab($keyword); } return false; }
thank you, i changed it up a bit because this test is a laravel command. I printed the result using this code and using the argument "apple":
` public function handle() { $keyword = $this->argument("keyword"); if (!empty($keyword)) { print_r("your keyword was " . $keyword . "\n"); print_r(\Buchin\GoogleImageGrabber\GoogleImageGrabber::grab($keyword)); return true; } print_r("your keyword was: " . $keyword . "\n"); return false; }
`
got this response:
your keyword was apple Array ( )
sorry, i'm not github saavy, i dont know how to style code properly
Go to your vendor folder and in "/buchin/google-image-grabber/src/GoogleImageGrabber.php" show me the code from line 109 to 167.
Go to your vendor folder and in "/buchin/google-image-grabber/src/GoogleImageGrabber.php" show me the code from line 109 to 167.
Below you'll find from 109 until the end of the file
`
$rawResults = [];
$results = [];
if (isset($data[31][0][12][2])) {
$rawResults = $data[31][0][12][2];
}
foreach ($rawResults as $rawResult) {
$result = [];
self::filterResult($rawResult, $result);
$data = self::getValues($result);
$result = [];
if (count($data) >= 11) {
$result["keyword"] = $keyword;
$result["slug"] = __::slug($keyword);
$result["title"] = isset($data[13])
? ucwords(__::slug($data[13], ["delimiter" => " "]))
: "";
$result["alt"] = isset($data[19])
? __::slug($data[19], ["delimiter" => " "])
: "";
$result["url"] = $data[8];
$result["filetype"] = self::getFileType($data[8]);
$result["width"] = $data[6];
$result["height"] = $data[7];
$result["source"] = isset($data[12]) ? $data[12] : "";
$result["domain"] = isset($data[20]) ? $data[20] : "";
$result["thumbnail"] = isset($data[26]) ? $data[26] : $data[1];
if (strpos($result["url"], "http") !== false) {
$results[] = $result;
}
$results[] = $result;
}
}
return $results;
}
public static function getFileType($url)
{
$url = strtolower($url);
switch ($url) {
case strpos($url, ".jpg") || strpos($url, ".jpeg"):
return "jpg";
break;
case strpos($url, ".png"):
return "png";
break;
case strpos($url, ".bmp"):
return "bmp";
break;
case strpos($url, ".gif"):
return "gif";
break;
default:
return "jpg";
break;
}
}
} `
I told you to update the repo to latest version. run composer update from your terminal to update it to latest.
I told you to update the repo to latest version. run composer update from your terminal to update it to latest.
I am sorry, i suppose the update didn't go through, below you'll see what the composer.lock file has:
` { "name": "buchin/google-image-grabber", "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/buchin/google-image-grabber.git", "reference": "1e257f1b0aeaa17f9f4ea89d60f2e3f7707cb37f" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/buchin/google-image-grabber/zipball/1e257f1b0aeaa17f9f4ea89d60f2e3f7707cb37f", "reference": "1e257f1b0aeaa17f9f4ea89d60f2e3f7707cb37f", "shasum": "" }, "require": { "campo/random-user-agent": "^1.2", "maciejczyzewski/bottomline": "^0.0.9" }, "require-dev": { "kahlan/kahlan": "dev-master" }, "type": "library", "autoload": { "psr-4": { "Buchin\GoogleImageGrabber\": "src/" } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { "name": "Mochammad Masbuchin", "email": "buchin@dropsugar.com" } ], "description": "Scrape google images", "support": { "issues": "https://github.com/buchin/google-image-grabber/issues", "source": "https://github.com/buchin/google-image-grabber/tree/1.0.3" }, "time": "2021-10-06T03:28:39+00:00" }
`
As i said run composer update and it will update everything including this repo. If its still not work then clear your composer cache using command composer clear-cache or download this repo manually and replace your vendor GoogleImageGrabber.php with the one you downloaded.
As i said run composer update and it will update everything including this repo. If its still not work then clear your composer cache using command composer clear-cache or download this repo manually and replace your vendor GoogleImageGrabber.php with the one you downloaded.
thank you, i did run composer update a bunch of times, even before continuing with the thread, also clearing the cache. I ended up doing the replacing of the GoogleImageGrabber.php manually.
it is working now, I appreciate the great work.
Add on Composer JSON this:
`"require-dev": { ... "campo/random-user-agent": "^1.2", "maciejczyzewski/bottomline": "^0.0.9" }
"require-dev": { .... "kahlan/kahlan": "dev-master" }`
Later remplace content of GoogleImageGrabber.php with the github content.
Work for me.
First of all, thanks for this amazing tool.
About a week ago, we stopped grabbing images from Google, it seems that something changed in the query that has to be sent, have you experienced anything?