Skip to content

Commit

Permalink
Merge pull request #30 from chriSmile0/release
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
chriSmile0 authored Jun 23, 2024
2 parents da2226e + 536b22e commit 35b0afd
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 17 deletions.
29 changes: 20 additions & 9 deletions src/scrapper_auchan.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,30 +316,41 @@ function extract_source_auchan(string $url,$driver, string $town, string $target
}
}

$driver->findElement(WebDriverBy::id('onetrust-accept-btn-handler'))->click(); // accept just try
$res_find = findElement_a($driver,"xpath","/html/body/div[14]/div[1]/main/div[1]/div[1]/div/div[1]/input",$res_find[1]);
$res_spe = "";
try {
$driver->wait(5)->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::id('onetrust-accept-btn-handler')));
$driver->findElement(WebDriverBy::id('onetrust-accept-btn-handler'))->click();
}
catch (Exception $e) {
$res_spe = $e->getMessage();
}
echo "|$res_spe|\n";

$res_find = findElement_a($driver,"xpath","/html/body/div[13]/div[1]/main/div[1]/div[1]/div/div[1]/input",$res_find[1],"visibility");
echo "AUCHA4:".$res_find[1]."\n";

if($res_find[0]!=="") $res_find[0]->sendKeys($town);
sleep(3); // for the moment
$driver->takeScreenshot("t.png");
sleep(1); // for the moment
//$driver->takeScreenshot("t.png");
try {
$driver->executeScript("(document.getElementsByClassName('journey__search-suggests-list')[0]).childNodes[0].click()");
}
catch(Exception $e) {
$res_find[1] = $e->getMessage();
}

sleep(3);
$driver->takeScreenshot("t2.png");
sleep(2);
//$driver->takeScreenshot("t2.png");


echo "AUCHA5:".$res_find[1]."\n";
$res_find = findElement_a($driver,"xpath","/html/body/div[14]/div[1]/main/div[1]/div[2]/div[2]/section/div[1]/div/div/div[2]/form/button",$res_find[1]);
$res_find = findElement_a($driver,"xpath","/html/body/div[13]/div[1]/main/div[1]/div[2]/div[2]/section/div[1]/div/div/div[2]/form/button",$res_find[1]);
if($res_find[0]!=="") $res_find[0]->submit();

sleep(10);
sleep(2);
echo "AUCHA6:".$res_find[1]."\n";
$driver->executeScript('window.scrollTo(0,200);');
$driver->takeScreenshot("t3.png");
//$driver->takeScreenshot("t3.png");
$error = $res_find[1];
$src = $driver->getPageSource();
}
Expand Down
1 change: 0 additions & 1 deletion src/scrapper_monoprix.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ function change_quantity_m(string $libelle) : string {
*/
function generate_driver_m(int $p, bool $web_server) {
//-----------------Remote with geckodriver in terminal--------------------//
var_dump($web_server);
if(!$web_server) {
$host = 'http://localhost:'.$p.'/';

Expand Down
2 changes: 1 addition & 1 deletion your_project/process_p.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ function post_to_otherphp_file(string $url, array $key_elements) {

//$url_ = 'pricecomparator.co/product/cities.php';
//post_to_otherphp_file($url_,["Monoprix"=>"Test"]);
//echo display_compare(["Monoprix"=>["Paris","Annecy"],"Carrefour"=>["Paris","Brest"]],"lardons","lardons"); // !!!!!!!!!!!!
echo display_compare(["Monoprix"=>["Paris"],"Auchan"=>["Annecy"]],"lardons","lardons"); // !!!!!!!!!!!!
//echo display_compare_web(["Monoprix"=>["Paris","Annecy"],"Carrefour"=>["Paris","Brest"]],"lardons","lardons");
//var_dump(display_compare(["Carrefour"=>["Paris"]],"lardons","lardons"));

Expand Down
14 changes: 8 additions & 6 deletions your_project/usage.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,16 @@ function globals_execs_locals(array $scrappers_usage) {
*/
function globals_execs_server(array $scrappers_usage) {// OK
$childs = array();
$recv_content = array();
$ports = 4444;
$returns = array();
$arrys = array();
$i = 0;
$cpt = 2; // POSSIBLE TO ADAPT BUT ONE RETRY IS I THINK OK WITH THE PATIENCE OF THE USER
$j = 0;
while(($j < $cpt) && !empty($scrappers_usage)) {
$l = 0;
$recv_content = array();
while(($l < $cpt) && (!empty($scrappers_usage))) {
//$recv_content = array();
echo "\nl : $l\n";
foreach($scrappers_usage as $key => $usages) {
$returns[$key] = [];
$portd = $ports+$i;
Expand Down Expand Up @@ -390,6 +392,7 @@ function globals_execs_server(array $scrappers_usage) {// OK
$returns[$pid[2]] = array_merge($returns[$pid[2]],[$pid[3]=>json_decode($rtn_tt,true)]);
$recv_content[$key][1] = true;
$recv_content[$key][3] = true;
//unset($scrappers_usage($rc[$key]))
}
}
}
Expand All @@ -401,17 +404,16 @@ function globals_execs_server(array $scrappers_usage) {// OK
}
}
}
var_dump($recv_content);
foreach($recv_content as $rc) { // check if we have all contents, if this is not the case we relaunch the forgot research
if($rc[3]==false) {
echo "re-LAUNCH :".$rc[0].", on port : ".$rc[2]."\n";
$i--;
}
else {
unset($scrappers_usage[$rc[0]]);
}
}
var_dump($scrappers_usage);
$j++;
$l++;
}
return $returns;
}
Expand Down

0 comments on commit 35b0afd

Please sign in to comment.