我在搜索bot爬蟲程序的項目中有一些特性/限制,我想使用代碼來測試它們,並且我發現有一個選項可以使用setHeader
方法設置標題。在我的情況下,它不工作。我得到[RuntimeException] Call to undefined method FunctionalTester::setHeader
錯誤。在代碼中設置用戶代理cept
代碼波紋管:
<?php
/** @var \Codeception\Scenario $scenario */
$I = new FunctionalTester($scenario);
$I->setHeader('User-Agent', 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)');
FileDetailPage::of($I)->amOnFileDetail(96972088, 'raped.zip');
根據Authorization header not making it through in Codeception API testing我不知道是否要設置用戶代理頭爲每個請求。是否有方法或配置選項永久更改用戶代理?
的setHeader方法只用PhpBrowser模塊工作,你能嗎? – Naktibalda
我使用基於phpbrowser的模塊,但很可能不支持設置標題,因爲我可以看到。謝謝你的幫助。 – Northys