Skip to content

Instantly share code, notes, and snippets.

@adirkuhn
Created April 4, 2019 20:18
Show Gist options
  • Save adirkuhn/6292ba2909507bb1c2e319a98b8d3e28 to your computer and use it in GitHub Desktop.
Save adirkuhn/6292ba2909507bb1c2e319a98b8d3e28 to your computer and use it in GitHub Desktop.
<?php
//first you need to retrieve the jsessionid and javax.ViewState
$url = 'https://www.visaovip.com/lista-preco';
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handle, CURLOPT_HEADER, 1);
$result = curl_exec($handle);
$matches = [];
preg_match('/JSESSIONID=([^;]+)/', $result, $matches);
$jSessionId = current($matches);
preg_match('/javax\.faces\.ViewState.*value="([^"]+)"/', $result, $matches);
$javaxFacesViewState = $matches[1];
//Then do the post
$fields = [
'formFaleConosco' => 'formFaleConosco',
'formListaPG' => 'formListaPG',
'formListaPG:j_idt72' => '',
'javax.faces.ViewState' => $javaxFacesViewState
];
$fields_string = http_build_query($fields);
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_POST, count($fields));
curl_setopt($handle, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($handle, CURLOPT_HTTPHEADER, [
'Content-Type: application/x-www-form-urlencoded',
'Connection: Keep-Alive',
'Cookie: primefaces.download=true;' . $jSessionId
]);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
//do the post
$result = curl_exec($handle);
//the fucking txt file
echo $result;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment