本文整理汇总了PHP中Goutte\Client::submit方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::submit方法的具体用法?PHP Client::submit怎么用?PHP Client::submit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Goutte\Client
的用法示例。
在下文中一共展示了Client::submit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scrap
public function scrap($username, $password)
{
$client = new Client();
$crawler = $client->request('GET', 'http://studentinfo.bdu.edu.et/login.aspx');
$form = $crawler->selectButton('Login')->form();
$form['dnn$ctr$Login$Login_DNN$txtUsername'] = $username;
$form['dnn$ctr$Login$Login_DNN$txtPassword'] = $password;
$crawler = $client->submit($form);
return $client->request('POST', 'MyGrades.aspx');
}
示例2: login
protected function login()
{
$page = $this->client->request('GET', 'http://fantasy.premierleague.com/');
$form = $page->selectButton('Log In')->form();
$this->client->submit($form, ['email' => Config::$username, 'password' => Config::$password, 'success' => 'http://fantasy.premierleague.com/accounts/login/', 'fail' => 'http://fantasy.premierleague.com/?fail']);
$this->is_logged_in = true;
}
示例3: getByDate
public function getByDate()
{
$client = new Client();
//$client->getClient()->setDefaultOption('config/curl/' . CURLOPT_SSL_VERIFYPEER, false);
$guzzleClient = new \GuzzleHttp\Client(array('curl' => array(CURLOPT_SSL_VERIFYPEER => false)));
$client->setClient($guzzleClient);
$crawler = $client->request('GET', 'https://portalcfdi.facturaelectronica.sat.gob.mx/');
$form = $crawler->filterXPath('//form')->form();
$crawler = $client->submit($form);
$link = $crawler->selectLink('Contraseña')->link();
$crawler = $client->request('GET', $link->getUri());
$form = $crawler->selectButton('Enviar')->form();
$form['Ecom_User_ID'] = 'GRI081024694';
$form['Ecom_Password'] = 'Kapa1324';
$crawler = $client->submit($form);
$form = $crawler->filterXPath('//form')->form();
$crawler = $client->submit($form);
$form = $crawler->filterXPath('//form')->first()->form();
$crawler = $client->submit($form);
$form = $crawler->filterXPath('//form')->first()->form();
$form['wresult'] = preg_replace('/\\s+/', '', $form->getValues()['wresult']);
//dd(preg_replace('/\s+/', '', $form->getValues()['wresult']));
$crawler = $client->submit($form);
echo $crawler->html();
//dd($crawler->html());
//dd($form->getValues()['wresult']);
}
示例4: extractPricesFromTable
/**
* Extracts prices from HTML table.
*
* @param string $button Submit button text
* @param array $location Region or county
* @return array
*/
protected function extractPricesFromTable($button, array $location)
{
$prices = [];
$crawler = $this->client->request('GET', 'http://www.ccs.cz/pages/phm2.php');
$form = $crawler->selectButton($button)->form();
$crawler = $this->client->submit($form, $location);
$columnIterator = 0;
$rowIterator = 0;
$crawler->filter('table[class="dynamic"] td')->each(function (DomCrawler $node) use(&$prices, &$columnIterator, &$rowIterator) {
switch ($columnIterator) {
case 0:
$prices[$rowIterator]['date'] = new \DateTime($node->text());
break;
case 1:
$prices[$rowIterator]['natural95'] = $node->text();
break;
case 3:
$prices[$rowIterator]['diesel'] = $node->text();
break;
}
$columnIterator = ++$columnIterator % 5;
$rowIterator += $columnIterator == 0 ? 1 : 0;
});
return $prices;
}
示例5: authenticateClient
protected function authenticateClient()
{
$crawler = $this->authenticatedClient->request('GET', $this->baseUrl . $this->loginPath);
$form = $crawler->selectButton($this->submitButtonText)->form();
$crawler = $this->authenticatedClient->submit($form, [$this->usernameField => $this->user['identifier'], $this->passwordField => $this->user['password']]);
$this->assertEquals($this->loggedInLinkText, $crawler->selectLink($this->loggedInLinkText)->text());
$this->printLn(sprintf('Authenticating with user %s wth role %s was Ok', $this->user['identifier'], $this->user['role']));
}
示例6: ensureLoggedIn
public function ensureLoggedIn()
{
$crawler = $this->client->request('GET', '/user/login');
/** @var Response $response */
$response = $this->client->getResponse();
if ($response->getStatus() < 200 && $response->getStatus() >= 300) {
return;
}
$loginForm = $crawler->filter('#loginPageForm')->form();
$this->client->submit($loginForm, ['username' => $this->username, 'password' => $this->password]);
if (strpos($this->client->getHistory()->current()->getUri(), 'account') === FALSE) {
throw new \PHPUnit_Framework_Exception("Should be logged in, but is not.");
}
}
示例7: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$licence = $input->getArgument('licence');
$center = $input->getArgument('center');
$filterDate = $input->getOption('filter');
$mail = $input->getOption('mail');
$client = new Client();
$crawler = $client->request('GET', 'https://driverpracticaltest.direct.gov.uk/application');
$output->writeln('Step 1');
$form = $crawler->selectButton('testTypeCar')->form();
$crawler = $client->submit($form);
$output->writeln('Step 2');
$form = $crawler->selectButton('drivingLicenceSubmit')->form();
$form->setValues(['driverLicenceNumber' => $licence, 'extendedTest' => 'false', 'specialNeeds' => 'false']);
$crawler = $client->submit($form);
$output->writeln('Step 3');
$form = $crawler->selectButton('testCentreSubmit')->form();
$form->setValues(['testCentreName' => $center]);
$crawler = $client->submit($form);
$output->writeln('Step 4');
$link = $crawler->filter('.test-centre-results > li > a')->first()->link();
$crawler = $client->click($link);
$output->writeln('Step 5');
$button = $crawler->selectButton('drivingLicenceSubmit');
if ($button->count() == 0) {
$output->writeln('Captcha!');
//TODO: display captcha image and ask to solve? Use decaptcha?
return;
}
$form = $button->form();
$date = (new \DateTime())->format('d/m/y');
$form->setValues(['preferredTestDate' => $date]);
$crawler = $client->submit($form);
$output->writeln('Step 6');
$slots = $crawler->filter('.slotDateTime');
$dates = $slots->each(function ($node, $i) use($output) {
return $node->text();
});
if ($filterDate) {
$filter = new DateFilter();
$dates = $filter->filterDates($dates, $filterDate);
}
foreach ($dates as $date) {
$output->writeln($date);
}
if (count($dates) && $mail) {
$mailer = new DateMailer();
$mailer->mail($mail, $dates);
}
}
示例8: testLoggedIn
public function testLoggedIn()
{
// we don't use the trait method here since we want our
// test to span two page requests, and we need to have
// the session persist on the remote server
// create a web client and hit the login page
$url = "http://localhost/login";
$client = new Client();
$crawler = $client->request('GET', $url);
$response_code = $client->getResponse()->getStatus();
// we should get 200 back
$this->assertEquals(200, $response_code);
// select the form on the page and populate values
// since we are using Goutte\Client, we don't need
// to worry about parsing the HTML to find the csrf _token
$form = $crawler->selectButton('Sign in')->form();
$form->setValues(['email' => 'me@here.ca', 'password' => 'verysecret']);
// submit the form
$client->submit($form);
$response_code_after_submit = $client->getResponse()->getStatus();
// make sure the HTML page displayed (response code 200
$this->assertEquals(200, $response_code_after_submit);
// make sure we can get to the testimonial page
$client->request('GET', 'http://localhost/add-testimonial');
$response_code = $client->getResponse()->getStatus();
$this->assertEquals(200, $response_code);
}
示例9: submit
/**
* Submits a form
*
* @param Symfony\Component\DomCrawler\Form $form A Form instance
* @param array $values An array of form field values
* @param bool $assert_response_html Should we perform standard assertions for a normal html page
* @return Symfony\Component\DomCrawler\Crawler
*/
public static function submit(Symfony\Component\DomCrawler\Form $form, array $values = array(), $assert_response_html = true)
{
$crawler = self::$client->submit($form, $values);
if ($assert_response_html) {
self::assert_response_html();
}
return $crawler;
}
示例10: execute
/**
* Execute load request.
*
* @return array
*/
public function execute()
{
$client = new Client();
$client->getClient()->setDefaultOption('verify', false);
$crawler = $client->request('GET', 'https://loadxtreme.ph/cgi-bin/webload.cgi?state=webload');
$form = $crawler->selectButton('SEND LOAD')->form();
$crawler = $client->submit($form, array('state' => 'webload', 'step' => '1', 'webtype' => '', 'uid' => $this->uid, 'pik' => $this->pik, 'pc' => $this->pc, 'cellno' => $this->cellno, 'email' => $this->email));
return $this->response($crawler->html());
}
示例11: check
public function check()
{
$client = new Client();
$crawler = $client->request('GET', 'http://www.abxexpress.com.my');
$trackBtn = $crawler->selectButton('Track');
$form = $trackBtn->form();
$crawler = $client->submit($form, array('tairbillno' => $this->tracking_no));
return $crawler->html();
}
示例12: testRequestHostedEndpointLive
/**
* @group liveTest
*/
public function testRequestHostedEndpointLive()
{
$requestDTO = $this->generatePaymentRequestDTO();
$response = $this->giropayHostedService->requestHostedEndpoint($requestDTO);
$this->assertInstanceOf("PHPCommerce\\Payment\\Dto\\PaymentResponseDTO", $response);
$redirectUrl = $response->getResponseMap()[GiropayConstants::HOSTED_REDIRECT_URL];
$client = new Client();
$crawler = $client->request('GET', $redirectUrl);
//bank login screen, login with test data
$this->assertEquals(200, $client->getResponse()->getStatus());
$this->assertContains("Online-Banking: Anmelden", $client->getResponse()->__toString());
$form = $crawler->selectButton('Sicher anmelden')->form();
$crawler = $client->submit($form, array('account/addition[@name=benutzerkennung]' => 'sepatest1', 'ticket/pin' => '12345'));
//
//validation screen, just click next button
$this->assertEquals(200, $client->getResponse()->getStatus());
$this->assertContains("Bitte wählen Sie eine Mobilfunknummer für den smsTAN-Versand", $client->getResponse()->__toString());
$form = $crawler->selectButton('weiterButton')->form();
$crawler = $client->submit($form, array());
//
//tan screen, enter tan
$this->assertEquals(200, $client->getResponse()->getStatus());
$this->assertContains("Bitte kontrollieren Sie vor der Eingabe der TAN die per SMS versandten Auftragsdaten", $client->getResponse()->__toString());
$form = $crawler->selectButton('absendenButton')->form();
$crawler = $client->submit($form, array('ticket/tan' => '123456'));
//
//success screen
$this->assertEquals(200, $client->getResponse()->getStatus());
$this->assertContains("Der Auftrag wurde entgegengenommen", $client->getResponse()->getContent()->__toString());
$form = $crawler->selectButton('back2MerchantButton')->form();
$crawler = $client->submit($form, array());
//
//redirect screen
$this->assertEquals(200, $client->getResponse()->getStatus());
$this->assertContains("Die Rücksprungadresse zum Händler wird ermittelt", $client->getResponse()->getContent()->__toString());
//wait until the redirect address is populated
sleep(3);
$client->followRedirects(false);
$form = $crawler->selectButton('go')->form();
$crawler = $client->submit($form, array());
$redirectUrl = $client->getResponse()->getHeader('Location');
//
}
示例13: obtener_info_cursos
function obtener_info_cursos($idCarrera)
{
$client = new Client();
//Obtengo creditos y validez del curso
$crawler = $client->request('GET', "http://www1.bedelias.edu.uy/ingenieria/muestra_mats.impr?car={$idCarrera}");
//Obtengo las tablas por área, y almaceno los cursos de cada una
$crawler->filter('.unoa')->each(function ($node, $index) use($idCarrera) {
if ($index == 0) {
return;
}
//De la tabla obtengo la informacion de los cursos
$datos_cursos = leer_tabla($node);
//Almaceno creditos y validez
foreach ($datos_cursos as $datos_curso) {
try {
guardar_creditos_validez($datos_curso[0], $datos_curso[1], $datos_curso[2]);
} catch (Exception $e) {
echo $e->getMessage();
}
}
});
//Obtengo porcentajes de aprobacion
$crawler = $client->request('GET', "http://www1.bedelias.edu.uy/ingenieria/actas_curso.sel_per_car");
//Obtengo los meses y obtengo los datos para cada periodo
$crawler->filter('select[name="p_permes"] option')->each(function ($node, $index) use($crawler, $client, $idCarrera) {
$form = $crawler->selectButton('Aceptar')->form();
$actas_mes = $client->submit($form, array('p_permes' => $node->text(), "p_curri" => "C", "p_carrcic" => $idCarrera));
//Por cada curso del periodo obtengo los datos
$actas_mes->filter('select[name="p_matnommat"] option')->each(function ($node, $index) use($actas_mes, $client) {
$form = $actas_mes->selectButton('Aceptar')->form();
$datos_curso = explode(" - ", $node->html());
$id_curso = trim($datos_curso[0]);
$acta_curso = $client->submit($form, array('p_matnommat' => $id_curso));
$datos = obtener_datos_aprobacion($acta_curso);
try {
//guardar_datos_aprobacion($id_curso, $datos);
} catch (Exception $e) {
echo $e->getMessage();
}
});
});
}
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$licence = $input->getArgument('licence');
$reference = $input->getArgument('reference');
$filterDate = $input->getOption('filter');
$mail = $input->getOption('mail');
$client = new Client();
$crawler = $client->request('GET', 'https://driverpracticaltest.direct.gov.uk/login');
$output->writeln('Step 1');
$form = $crawler->selectButton('booking-login')->form();
$form->setValues(['username' => $licence, 'password' => $reference]);
$crawler = $client->submit($form);
$output->writeln('Step 2');
$link = $crawler->filter('#date-time-change')->first()->link();
$crawler = $client->click($link);
$output->writeln('Step 3');
$button = $crawler->selectButton('drivingLicenceSubmit');
if ($button->count() == 0) {
$output->writeln('Captcha!');
//TODO: display captcha image and ask to solve? Use decaptcha?
return;
}
$form = $button->form();
$crawler = $client->submit($form);
$output->writeln('Step 4');
$slots = $crawler->filter('.slotDateTime');
$dates = $slots->each(function ($node, $i) use($output) {
return $node->text();
});
if ($filterDate) {
$filter = new DateFilter();
$dates = $filter->filterDates($dates, $filterDate);
}
foreach ($dates as $date) {
$output->writeln($date);
}
if (count($dates) && $mail) {
$mailer = new DateMailer();
$mailer->mail($mail, $dates);
}
}
示例15: authenticate
public static function authenticate()
{
$client = new Client();
$crawler = $client->request('GET', Conf::DOMAIN . "/");
// select the form and fill in some values
$form = $crawler->filter('body > div > form')->form();
$form['email'] = Conf::EMAIL;
$form['password'] = Conf::PASS;
// submit that form
$crawler = $client->submit($form);
return $client;
}