我正在尝试通过 CSS 选择器或 xpath 表达式从给定文本中获取值,但我不知道是否可以执行此操作。这是我的 HTML:
<select name="product" style="width: 430px">
<option value="0" selected="selected"></option>
<option value="3181">389-ds-base</option>
<option value="3511">7-Zip</option>
假设我想通过给出文本来获得值 3511。
我想要这个的原因是因为我想做这样的网络爬行:
require_once '/root/PHP/goutte.phar';
use Goutte\Client;
$client = new Client();
$crawler = $client->request('GET', 'https://oval.mitre.org/repository/data/search/');
$form = $crawler->selectButton('Search')->form();
$crawler = $client->submit($form, array('product' => '3511'));
$nodeValues = $crawler->filterXPath('//td[@nowrap][position()>4]/a')->each(function ($node) {
return $node->text();
});
而且我不想将数字 3511 作为参数传递,而是传递文本。
希望我说清楚了,提前谢谢你。