1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys AirBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\AirBundle\Command
;
14 use Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand
;
15 use Doctrine\Persistence\ManagerRegistry
;
17 use Symfony\Component\Console\Input\InputInterface
;
18 use Symfony\Component\Console\Output\OutputInterface
;
19 use Symfony\Component\Filesystem\Exception\IOException
;
20 use Symfony\Component\Filesystem\Filesystem
;
22 use Rapsys\AirBundle\Entity\Session
;
24 class WeatherCommand
extends DoctrineCommand
{
25 //Set failure constant
28 ///Set success constant
33 //Mostly useless in fact
35 //Required to simplify simplexml transition
37 //Required to avoid xml errors
38 'quote-nbsp' => false,
39 //Required to fix code
43 ///Set accuweather uris
44 private $accuweather = [
47 75001 => 'https://www.accuweather.com/en/fr/paris-01-louvre/75001/hourly-weather-forecast/179142_pc?day=',
48 75004 => 'https://www.accuweather.com/en/fr/paris-04-hotel-de-ville/75004/hourly-weather-forecast/179145_pc?day=',
49 75005 => 'https://www.accuweather.com/en/fr/paris-05-pantheon/75005/hourly-weather-forecast/179146_pc?day=',
50 75006 => 'https://www.accuweather.com/fr/fr/paris-06-luxembourg/75006/hourly-weather-forecast/179147_pc?day=',
51 75007 => 'https://www.accuweather.com/en/fr/paris-07-palais-bourbon/75007/hourly-weather-forecast/179148_pc?day=',
52 75009 => 'https://www.accuweather.com/en/fr/paris-09-opera/75009/hourly-weather-forecast/179150_pc?day=',
53 75010 => 'https://www.accuweather.com/en/fr/paris-10-entrepot/75010/hourly-weather-forecast/179151_pc?day=',
54 75012 => 'https://www.accuweather.com/en/fr/paris-12-reuilly/75012/hourly-weather-forecast/179153_pc?day=',
55 75013 => 'https://www.accuweather.com/en/fr/paris-13-gobelins/75013/hourly-weather-forecast/179154_pc?day=',
56 75015 => 'https://www.accuweather.com/en/fr/paris-15-vaugirard/75015/hourly-weather-forecast/179156_pc?day=',
57 75019 => 'https://www.accuweather.com/en/fr/paris-19-buttes-chaumont/75019/hourly-weather-forecast/179160_pc?day=',
58 75116 => 'https://www.accuweather.com/en/fr/paris-16-passy/75116/hourly-weather-forecast/179246_pc?day='
62 75001 => 'https://www.accuweather.com/en/fr/paris-01-louvre/75001/10-day-weather-forecast/179142_pc?page=%7Bpage%7D',
63 75004 => 'https://www.accuweather.com/en/fr/paris-04-hotel-de-ville/75004/10-day-weather-forecast/179145_pc?page=%7Bpage%7D',
64 75005 => 'https://www.accuweather.com/en/fr/paris-05-pantheon/75005/10-day-weather-forecast/179146_pc?page=%7Bpage%7D',
65 75006 => 'https://www.accuweather.com/fr/fr/paris-06-luxembourg/75006/10-day-weather-forecast/179147_pc?page=%7Bpage%7D',
66 75007 => 'https://www.accuweather.com/en/fr/paris-07-palais-bourbon/75007/10-day-weather-forecast/179148_pc?page=%7Bpage%7D',
67 75009 => 'https://www.accuweather.com/en/fr/paris-09-opera/75009/10-day-weather-forecast/179150_pc?page=%7Bpage%7D',
68 75010 => 'https://www.accuweather.com/en/fr/paris-10-entrepot/75010/10-day-weather-forecast/179151_pc?page=%7Bpage%7D',
69 75012 => 'https://www.accuweather.com/en/fr/paris-12-reuilly/75012/10-day-weather-forecast/179153_pc?page=%7Bpage%7D',
70 75013 => 'https://www.accuweather.com/en/fr/paris-13-gobelins/75013/10-day-weather-forecast/179154_pc?page=%7Bpage%7D',
71 75015 => 'https://www.accuweather.com/en/fr/paris-15-vaugirard/75015/10-day-weather-forecast/179156_pc?page=%7Bpage%7D',
72 75019 => 'https://www.accuweather.com/en/fr/paris-19-buttes-chaumont/75019/10-day-weather-forecast/179160_pc?page=%7Bpage%7D',
73 75116 => 'https://www.accuweather.com/en/fr/paris-16-passy/75116/10-day-weather-forecast/179246_pc?page=%7Bpage%7D'
78 private \CurlHandle
|false $ch = false;
80 ///Weather command constructor
81 public function __construct(private ManagerRegistry
$doctrine, private Filesystem
$filesystem) {
82 parent
::__construct($doctrine);
85 ///Configure attribute command
86 protected function configure():void {
90 ->setName('rapsysair:weather')
91 //Set description shown with bin/console list
92 ->setDescription('Updates session rain and temperature fields')
93 //Set description shown with bin/console --help airlibre:attribute
94 ->setHelp('This command updates session rain and temperature fields in next three days')
95 //Add daily and hourly aliases
96 ->setAliases(['rapsysair:weather:daily', 'rapsysair:weather:hourly']);
99 ///Process the attribution
100 protected function execute(InputInterface
$input, OutputInterface
$output): int {
102 $kernel = $this->getApplication()->getKernel();
105 $tmpdir = $kernel->getContainer()->getParameter('kernel.project_dir').'/var/cache/weather';
108 //XXX: worst case scenario we have 3 files per zipcode plus daily
109 if (!is_dir($tmpdir)) {
112 $this->filesystem
->mkdir($tmpdir, 0775);
113 } catch (IOException
$exception) {
115 echo 'Create dir '.$exception->getPath().' failed'."\n";
128 //Init zipcodes array
134 //Process hourly accuweather
135 if (($command = $input->getFirstArgument()) == 'rapsysair:weather:hourly' || $command == 'rapsysair:weather') {
136 //Fetch hourly sessions to attribute
137 $types['hourly'] = $this->doctrine
->getRepository(Session
::class)->findAllPendingHourlyWeather();
139 //Iterate on each session
140 foreach($types['hourly'] as $sessionId => $session) {
142 $zipcode = $session->getLocation()->getZipcode();
145 $start = $session->getStart();
148 $day = $start->diff((new \
DateTime('now'))->setTime(0, 0, 0))->d +
1;
150 //Check if zipcode is set
151 if (!isset($zipcodes[$zipcode])) {
152 $zipcodes[$zipcode] = [];
155 //Check if zipcode date is set
156 if (!isset($zipcodes[$zipcode][$day])) {
157 $zipcodes[$zipcode][$day] = [ $sessionId => $sessionId ];
159 $zipcodes[$zipcode][$day][$sessionId] = $sessionId;
163 $stop = $session->getStop();
166 $day = $stop->diff((new \
DateTime('now'))->setTime(0, 0, 0))->d +
1;
169 //XXX: accuweather only allow until 3rd day
174 //Check if zipcode date is set
175 if (!isset($zipcodes[$zipcode][$day])) {
176 $zipcodes[$zipcode][$day] = [ $sessionId => $sessionId ];
178 $zipcodes[$zipcode][$day][$sessionId] = $sessionId;
183 //Process daily accuweather
184 if ($command == 'rapsysair:weather:daily' || $command == 'rapsysair:weather') {
185 //Fetch daily sessions to attribute
186 $types['daily'] = $this->doctrine
->getRepository(Session
::class)->findAllPendingDailyWeather();
188 //Iterate on each session
189 foreach($types['daily'] as $sessionId => $session) {
191 $zipcode = $session->getLocation()->getZipcode();
194 $start = $session->getStart();
199 //Check if zipcode is set
200 if (!isset($zipcodes[$zipcode])) {
201 $zipcodes[$zipcode] = [];
204 //Check if zipcode date is set
205 if (!isset($zipcodes[$zipcode][$day])) {
206 $zipcodes[$zipcode][$day] = [ $sessionId => $sessionId ];
208 $zipcodes[$zipcode][$day][$sessionId] = $sessionId;
214 $this->curl_init($tmpdir);
219 //Iterate on zipcodes
220 foreach($zipcodes as $zipcode => $days) {
222 foreach($days as $day => $null) {
223 //Try to load content from cache
224 if (!is_file($file = $tmpdir.'/'.$zipcode.'.'.$day.'.html') || stat($file)['ctime'] <= (time() - ($day == 'daily' ? 4 : 2)*3600) || ($content = file_get_contents($file)) === false) {
225 //Prevent timing detection
226 //XXX: from 0.1 to 5 seconds
227 usleep(rand(1,50) * 100000);
230 //TODO: for daily we may load data for requested quarter of the day
231 $content = $this->curl_get($day == 'daily' ? $this->accuweather
['daily'][$zipcode] : $this->accuweather
['hourly'][$zipcode].$day);
234 if (file_put_contents($tmpdir.'/'.$zipcode.'.'.$day.'.html', $content) === false) {
236 echo 'Write to '.$tmpdir.'/'.$zipcode.'.'.$day.'.html failed'."\n";
244 $tidy->parseString($content, $this->config
, 'utf8');
247 //XXX: don't care about theses errors, tidy is here to fix...
248 #if (!empty($tidy->errorBuffer)) {
249 # var_dump($tidy->errorBuffer);
250 # die('Tidy errors');
254 //XXX: trash all xmlns= broken tags
255 $sx = new \
SimpleXMLElement(str_replace(['xmlns=', 'xlink:href='], ['xns=', 'href='], (string)$tidy));
258 if ($day == 'daily') {
259 //Iterate on each link containing data
260 foreach($sx->xpath('//a[contains(@class,"daily-forecast-card")]') as $node) {
262 $dsm = trim((string)$node->div
[0]->h2
[0]->span
[1]);
265 $temperature = str_replace('°', '', (string)$node->div
[0]->div
[0]->span
[0]);
268 $rainrisk = trim(str_replace('%', '', (string)$node->div
[1]))/100;
271 $data[$zipcode][$dsm]['daily'] = [
272 'temperature' => $temperature,
273 'rainrisk' => $rainrisk
278 //Iterate on each div containing data
279 #(string)$sx->xpath('//div[@class="hourly-card-nfl"]')[0]->attributes()->value
280 #/html/body/div[1]/div[5]/div[1]/div[1]/div[1]/div[1]/div[1]/div/h2/span[1]
281 foreach($sx->xpath('//div[@data-shared="false"]') as $node) {
283 $hour = trim(str_replace(' h', '', (string)$node->div
[0]->div
[0]->div
[0]->div
[0]->div
[0]->h2
[0]));
285 //Compute dsm from day (1=d,2=d+1,3=d+2)
286 $dsm = (new \
DateTime('+'.($day - 1).' day'))->format('d/m');
289 $temperature = str_replace('°', '', (string)$node->div
[0]->div
[0]->div
[0]->div
[0]->div
[1]);
292 $realfeel = trim(str_replace(['RealFeel®', '°'], '', (string)$node->div
[0]->div
[0]->div
[0]->div
[1]->div
[0]->div
[0]->div
[0]));
295 $rainrisk = floatval(str_replace('%', '', trim((string)$node->div
[0]->div
[0]->div
[0]->div
[2]->div
[0]))/100);
297 //Set rainfall to 0 (mm)
300 //Iterate on each entry
301 //TODO: wind and other infos are present in $node->div[1]->div[0]->div[1]->div[0]->p
302 foreach($node->div
[1]->div
[0]->div
[1]->div
[0]->p
as $p) {
303 //Lookup for rain entry if present
304 if (in_array(trim((string)$p), ['Rain', 'Pluie'])) {
306 $rainfall = floatval(str_replace(' mm', '', (string)$p->span
[0]));
311 $data[$zipcode][$dsm][$hour] = [
312 'temperature' => $temperature,
313 'realfeel' => $realfeel,
314 'rainrisk' => $rainrisk,
315 'rainfall' => $rainfall
326 foreach($types as $type => $sessions) {
327 //Iterate on each type
328 foreach($sessions as $sessionId => $session) {
330 $zipcode = $session->getLocation()->getZipcode();
333 $start = $session->getStart();
336 if ($type == 'daily') {
338 $period = [ $start ];
342 $stop = $session->getStop();
345 $period = new \
DatePeriod(
348 //Iterate on each hour
349 new \
DateInterval('PT1H'),
350 //End with begin + length
360 'realfeelmin' => null,
361 'realfeelmax' => null,
363 'temperaturemin' => null,
364 'temperaturemax' => null
367 //Iterate on the period
368 foreach($period as $time) {
370 $dsm = $time->format('d/m');
373 $hour = $type=='daily'?$type:$time->format('H');
375 //Check data availability
376 //XXX: sometimes startup delay causes weather data to be unavailable for session first hour
377 if (!isset($data[$zipcode][$dsm][$hour])) {
378 //Skip unavailable data
383 $info = $data[$zipcode][$dsm][$hour];
385 //Check if rainrisk is higher
386 if ($meteo['rainrisk'] === null || $info['rainrisk'] > $meteo['rainrisk']) {
387 //Set highest rain risk
388 $meteo['rainrisk'] = floatval($info['rainrisk']);
391 //Check if rainfall is set
392 if (isset($info['rainfall'])) {
394 $meteo['rainfall'] +
= floatval($info['rainfall']);
398 $meteo['temperature'][$hour] = $info['temperature'];
401 if ($type != 'daily') {
402 //Check min temperature
403 if ($meteo['temperaturemin'] === null || $info['temperature'] < $meteo['temperaturemin']) {
404 $meteo['temperaturemin'] = floatval($info['temperature']);
407 //Check max temperature
408 if ($meteo['temperaturemax'] === null || $info['temperature'] > $meteo['temperaturemax']) {
409 $meteo['temperaturemax'] = floatval($info['temperature']);
413 //Check if realfeel is set
414 if (isset($info['realfeel'])) {
416 $meteo['realfeel'][$hour] = $info['realfeel'];
419 if ($meteo['realfeelmin'] === null || $info['realfeel'] < $meteo['realfeelmin']) {
420 $meteo['realfeelmin'] = floatval($info['realfeel']);
424 if ($meteo['realfeelmax'] === null || $info['realfeel'] > $meteo['realfeelmax']) {
425 $meteo['realfeelmax'] = floatval($info['realfeel']);
430 //Check if rainfall is set and differ
431 if ($session->getRainfall() !== $meteo['rainfall']) {
433 $session->setRainfall($meteo['rainfall']);
436 //Check if rainrisk differ
437 if ($session->getRainrisk() !== $meteo['rainrisk']) {
439 $session->setRainrisk($meteo['rainrisk']);
442 //Check realfeel array
443 if ($meteo['realfeel'] !== []) {
445 $realfeel = floatval(round(array_sum($meteo['realfeel'])/count($meteo['realfeel']),1));
447 //Check if realfeel differ
448 if ($session->getRealfeel() !== $realfeel) {
449 //Set average realfeel
450 $session->setRealfeel($realfeel);
453 //Check if realfeelmin differ
454 if ($session->getRealfeelmin() !== $meteo['realfeelmin']) {
456 $session->setRealfeelmin($meteo['realfeelmin']);
459 //Check if realfeelmax differ
460 if ($session->getRealfeelmax() !== $meteo['realfeelmax']) {
462 $session->setRealfeelmax($meteo['realfeelmax']);
466 //Check temperature array
467 if ($meteo['temperature'] !== []) {
468 //Compute temperature
469 $temperature = floatval(round(array_sum($meteo['temperature'])/count($meteo['temperature']),1));
471 //Check if temperature differ
472 if ($session->getTemperature() !== $temperature) {
473 //Set average temperature
474 $session->setTemperature($temperature);
477 //Check if temperaturemin differ
478 if ($session->getTemperaturemin() !== $meteo['temperaturemin']) {
480 $session->setTemperaturemin($meteo['temperaturemin']);
483 //Check if temperaturemax differ
484 if ($session->getTemperaturemax() !== $meteo['temperaturemax']) {
486 $session->setTemperaturemax($meteo['temperaturemax']);
492 //Flush to get the ids
493 $this->doctrine
->getManager()->flush();
496 return self
::SUCCESS
;
502 * @return bool|void Return success or exit
504 function curl_init(string $tmpdir) {
506 if (($this->ch
= curl_init()) === false) {
508 echo 'Curl init failed: '.curl_error($this->ch
)."\n";
519 CURLOPT_HTTP_VERSION
=> CURL_HTTP_VERSION_2_0
,
521 CURLOPT_ACCEPT_ENCODING
=> '',
523 CURLOPT_HTTPHEADER
=> [
524 //XXX: it seems that you can disable akamai fucking protection with Pragma: akamai-x-cache-off
525 //XXX: see https://support.globaldots.com/hc/en-us/articles/115003996705-Akamai-Pragma-Headers-overview
526 #'Pragma: akamai-x-cache-off',
527 //XXX: working curl command
528 #curl --http2 --cookie file.jar --cookie-jar file.jar -v -i -k -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' -H 'Accept-Language: en-GB,en;q=0.9' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Host: www.accuweather.com' -H 'Pragma: no-cache' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36' 'https://www.accuweather.com/'
530 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
532 'Accept-Encoding: gzip, deflate, br, zstd',
533 //Set accept language
534 'Accept-Language: en-GB,en;q=0.9',
536 'Cache-Control: no-cache',
537 //Keep connection alive
538 #XXX: to drop? 'Connection: keep-alive',
546 'Sec-CH-UA: "Chromium";v="148", "Google Chrome";v="148", "Not/A)Brand";v="99"',
550 'Sec-CH-UA-Platform: "Windows"',
552 'Sec-Fetch-Dest: document',
554 'Sec-Fetch-Mode: navigate',
556 'Sec-Fetch-Site: none',
558 'Sec-Fetch-User: ?1',
559 //Force secure requests
560 'Upgrade-Insecure-Requests: 1',
562 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/148.0.0.0 Safari/537.36',
563 //Force akamai cookie
564 //XXX: seems to come from http request
566 //TODO: add akamai cookie ?
567 //XXX: see https://www.ford.eu/cookie-guide
568 #ak_bmsc: ajouter ? valable un jour ?
569 #request-context: appId=cid-v1:69db91ae-4014-4da6-962b-6e1205fccce5
570 #< permissions-policy: browsing-topics=()
571 #permissions-policy: browsing-topics=()
572 #< vary: Accept-Encoding
573 #vary: Accept-Encoding
574 #< content-encoding: gzip
575 #content-encoding: gzip
576 #< date: Mon, 23 Mar 2026 22:36:43 GMT
577 #date: Mon, 23 Mar 2026 22:36:43 GMT
578 #< content-length: 39349
579 #content-length: 39349
580 #* Added cookie awx_id="1062821a-a1f2-42be-82ec-859a2aac16ef" for domain www.accuweather.com, path /, expire 1805841403
581 #< set-cookie: awx_id=1062821a-a1f2-42be-82ec-859a2aac16ef; expires=Tue, 23 Mar 2027 22:36:43 GMT; path=/; secure; httponly
582 #set-cookie: awx_id=1062821a-a1f2-42be-82ec-859a2aac16ef; expires=Tue, 23 Mar 2027 22:36:43 GMT; path=/; secure; httponly
583 #* Added cookie awx_session_essential="id%3A614c5979-6977-444e-a900-c0834e6602fb%7CpageView%3A1" for domain www.accuweather.com, path /, expire 1774306003
584 #< set-cookie: awx_session_essential=id%3A614c5979-6977-444e-a900-c0834e6602fb%7CpageView%3A1; expires=Mon, 23 Mar 2026 22:46:43 GMT; path=/; secure; samesite=lax; httponly
585 #set-cookie: awx_session_essential=id%3A614c5979-6977-444e-a900-c0834e6602fb%7CpageView%3A1; expires=Mon, 23 Mar 2026 22:46:43 GMT; path=/; secure; samesite=lax; httponly
587 #* Replaced cookie awx_id="1062821a-a1f2-42be-82ec-859a2aac16ef" for domain www.accuweather.com, path /, expire 1805841454
588 #< set-cookie: awx_id=1062821a-a1f2-42be-82ec-859a2aac16ef; expires=Tue, 23 Mar 2027 22:37:34 GMT; path=/; secure; httponly
589 #set-cookie: awx_id=1062821a-a1f2-42be-82ec-859a2aac16ef; expires=Tue, 23 Mar 2027 22:37:34 GMT; path=/; secure; httponly
590 #* Replaced cookie awx_session_essential="id%3A614c5979-6977-444e-a900-c0834e6602fb%7CpageView%3A2" for domain www.accuweather.com, path /, expire 1774306054
591 #< set-cookie: awx_session_essential=id%3A614c5979-6977-444e-a900-c0834e6602fb%7CpageView%3A2; expires=Mon, 23 Mar 2026 22:47:34 GMT; path=/; secure; samesite=lax; httponly
592 #set-cookie: awx_session_essential=id%3A614c5979-6977-444e-a900-c0834e6602fb%7CpageView%3A2; expires=Mon, 23 Mar 2026 22:47:34 GMT; path=/; secure; samesite=lax; httponly
593 #< strict-transport-security: max-age=15768000 ; includeSubDomains ; preload
594 #strict-transport-security: max-age=15768000 ; includeSubDomains ; preload
595 #* Added cookie ak_bmsc="010A87851EDC882D1FE84B535E75D0C6~000000000000000000000000000000~YAAQfOIlF3lI//WcAQAAZqrYHB/DJCb/+t9xHWxhT1EDW/Qe8778baYOLuqlhfzRUU1m6YXWfZjRJlfkpMYg5WdzrV2Y0WtHuiTknE9/AMA9MTh82uI4z4xr3Rv3TeZjG+ggc05Sp2rKiyYjHxgq7ZN9fHAFS0Mqab+DTtTtAZaSCeBc96tb+hg0c3TEXZSDRStGppvA1ejPTO1Q3jZ+PIXZ0NzR3LN4DcpmvgtcB1A4vIsIuXhqbsvz6ns2XdKIYgvrdY6v0mJA6+EbAv+O/u0WRlcM1akq5+Cahmm8lgpy52DRuq82lwLR0JwtUHc+JjukuY9bWSi595VZvehTyhnjXHqSY7M1qhpJ9IVR9wFRWWFo5SSOZpEW5xsl+n2Aph4XHkuEKxc2TnqXHA4fdgM=" for domain accuweather.com, path /, expire 1774312654
596 #< set-cookie: ak_bmsc=010A87851EDC882D1FE84B535E75D0C6~000000000000000000000000000000~YAAQfOIlF3lI//WcAQAAZqrYHB/DJCb/+t9xHWxhT1EDW/Qe8778baYOLuqlhfzRUU1m6YXWfZjRJlfkpMYg5WdzrV2Y0WtHuiTknE9/AMA9MTh82uI4z4xr3Rv3TeZjG+ggc05Sp2rKiyYjHxgq7ZN9fHAFS0Mqab+DTtTtAZaSCeBc96tb+hg0c3TEXZSDRStGppvA1ejPTO1Q3jZ+PIXZ0NzR3LN4DcpmvgtcB1A4vIsIuXhqbsvz6ns2XdKIYgvrdY6v0mJA6+EbAv+O/u0WRlcM1akq5+Cahmm8lgpy52DRuq82lwLR0JwtUHc+JjukuY9bWSi595VZvehTyhnjXHqSY7M1qhpJ9IVR9wFRWWFo5SSOZpEW5xsl+n2Aph4XHkuEKxc2TnqXHA4fdgM=; Domain=.accuweather.com; Path=/; Expires=Tue, 24 Mar 2026 00:37:34 GMT; Max-Age=7200; HttpOnly
597 #set-cookie: ak_bmsc=010A87851EDC882D1FE84B535E75D0C6~000000000000000000000000000000~YAAQfOIlF3lI//WcAQAAZqrYHB/DJCb/+t9xHWxhT1EDW/Qe8778baYOLuqlhfzRUU1m6YXWfZjRJlfkpMYg5WdzrV2Y0WtHuiTknE9/AMA9MTh82uI4z4xr3Rv3TeZjG+ggc05Sp2rKiyYjHxgq7ZN9fHAFS0Mqab+DTtTtAZaSCeBc96tb+hg0c3TEXZSDRStGppvA1ejPTO1Q3jZ+PIXZ0NzR3LN4DcpmvgtcB1A4vIsIuXhqbsvz6ns2XdKIYgvrdY6v0mJA6+EbAv+O/u0WRlcM1akq5+Cahmm8lgpy52DRuq82lwLR0JwtUHc+JjukuY9bWSi595VZvehTyhnjXHqSY7M1qhpJ9IVR9wFRWWFo5SSOZpEW5xsl+n2Aph4XHkuEKxc2TnqXHA4fdgM=; Domain=.accuweather.com; Path=/; Expires=Tue, 24 Mar 2026 00:37:34 GMT; Max-Age=7200; HttpOnly
598 #* Added cookie bm_mi="F052B40D9957D87932CF91B3BCD53103~YAAQfOIlF3pI//WcAQAAZqrYHB8MhsqiidkryWWG/FELf+Jop+KjoERXKsZW/oxZ+c6ldIx5C8iwD7ReaDYhYufdjAYrxGXN6LkLRd17iwN/5USm1sOBD3V1XD9K4ftXO6eBsjIxI9lfZvY8KN/HCAMLPn68AbLWCDNyNuku9oOc4cr4CqrTVdoz73o4crl1BVwm2bIxeXGnG5FhznRy3+99KgY6IjinBcHKaUIATLOgrvjwkTKB19/m4DWOpp805vVbaa6EdhuTAM2KjaNK6DUx9WR+GVWBQ63X0SJ+4lAT2qVWCWrfVWmDijgunHoTmQvbJHliBpapOvUe3ShoZOMromAbzvfuSO//PIwGNPEgvq8FDD19nNyZCAArgTkg11pXAgH8jaZRon811vKVu3+nyNM=~1" for domain accuweather.com, path /, expire 1
599 #< set-cookie: bm_mi=F052B40D9957D87932CF91B3BCD53103~YAAQfOIlF3pI//WcAQAAZqrYHB8MhsqiidkryWWG/FELf+Jop+KjoERXKsZW/oxZ+c6ldIx5C8iwD7ReaDYhYufdjAYrxGXN6LkLRd17iwN/5USm1sOBD3V1XD9K4ftXO6eBsjIxI9lfZvY8KN/HCAMLPn68AbLWCDNyNuku9oOc4cr4CqrTVdoz73o4crl1BVwm2bIxeXGnG5FhznRy3+99KgY6IjinBcHKaUIATLOgrvjwkTKB19/m4DWOpp805vVbaa6EdhuTAM2KjaNK6DUx9WR+GVWBQ63X0SJ+4lAT2qVWCWrfVWmDijgunHoTmQvbJHliBpapOvUe3ShoZOMromAbzvfuSO//PIwGNPEgvq8FDD19nNyZCAArgTkg11pXAgH8jaZRon811vKVu3+nyNM=~1; Domain=.accuweather.com; Path=/; Expires=Mon, 23 Mar 2026 22:37:34 GMT; Max-Age=0; Secure
600 #set-cookie: bm_mi=F052B40D9957D87932CF91B3BCD53103~YAAQfOIlF3pI//WcAQAAZqrYHB8MhsqiidkryWWG/FELf+Jop+KjoERXKsZW/oxZ+c6ldIx5C8iwD7ReaDYhYufdjAYrxGXN6LkLRd17iwN/5USm1sOBD3V1XD9K4ftXO6eBsjIxI9lfZvY8KN/HCAMLPn68AbLWCDNyNuku9oOc4cr4CqrTVdoz73o4crl1BVwm2bIxeXGnG5FhznRy3+99KgY6IjinBcHKaUIATLOgrvjwkTKB19/m4DWOpp805vVbaa6EdhuTAM2KjaNK6DUx9WR+GVWBQ63X0SJ+4lAT2qVWCWrfVWmDijgunHoTmQvbJHliBpapOvUe3ShoZOMromAbzvfuSO//PIwGNPEgvq8FDD19nNyZCAArgTkg11pXAgH8jaZRon811vKVu3+nyNM=~1; Domain=.accuweather.com; Path=/; Expires=Mon, 23 Mar 2026 22:37:34 GMT; Max-Age=0; Secure
605 CURLOPT_COOKIEFILE
=> $tmpdir.'/cookies.txt',
606 //Disable location following
607 CURLOPT_FOLLOWLOCATION
=> false,
609 #CURLOPT_URL => $url = 'https://www.accuweather.com/',
611 CURLOPT_HEADER
=> true,
613 CURLOPT_RETURNTRANSFER
=> true,
616 CURLINFO_HEADER_OUT
=> true
621 echo 'Curl setopt array failed: '.curl_error($this->ch
)."\n";
633 * @return string|void Return url content or exit
635 function curl_get($url) {
637 if (curl_setopt($this->ch
, CURLOPT_URL
, $url) === false) {
639 echo 'Setopt for '.$url.' failed: '.curl_error($this->ch
)."\n";
645 //Check return status
646 if (($response = curl_exec($this->ch
)) === false) {
648 echo 'Get for '.$url.' failed: '.curl_error($this->ch
)."\n";
650 //Display sent headers
651 var_dump(curl_getinfo($this->ch
, CURLINFO_HEADER_OUT
));
661 if (empty($hs = curl_getinfo($this->ch
, CURLINFO_HEADER_SIZE
))) {
663 echo 'Getinfo for '.$url.' failed: '.curl_error($this->ch
)."\n";
665 //Display sent headers
666 var_dump(curl_getinfo($this->ch
, CURLINFO_HEADER_OUT
));
676 if (empty($header = substr($response, 0, $hs))) {
678 echo 'Header for '.$url.' empty: '.curl_error($this->ch
)."\n";
680 //Display sent headers
681 var_dump(curl_getinfo($this->ch
, CURLINFO_HEADER_OUT
));
690 //Check request success
691 if (strlen($header) <= 10 || substr($header, 0, 10) !== 'HTTP/2 200') {
693 echo 'Status for '.$url.' failed: '.curl_error($this->ch
)."\n";
695 //Display sent headers
696 var_dump(curl_getinfo($this->ch
, CURLINFO_HEADER_OUT
));
706 return substr($response, $hs);