【发布时间】:2022-01-04 05:56:52
【问题描述】:
我的 elemenet 在其他站点触发点击时发生了变化。 是否可以使用 php guzzle 运行 jQuery 脚本,然后将新元素值放入我的存储变量中? 这是我的代码
<?php
# scraping books to scrape: https://books.toscrape.com/
require 'vendor/autoload.php';
$httpClient = new \GuzzleHttp\Client();
$response = $httpClient->get('webpage');
$htmlString = (string) $response->getBody();
//add this line to suppress any warnings
libxml_use_internal_errors(true);
$doc = new DOMDocument();
$doc->loadHTML($htmlString);
$xpath = new DOMXPath($doc);
$prices = $xpath->evaluate('//div[@class="price"]//p[@class="our_price_display"]//span[@class="price"]');
foreach ($prices as $key => $price) {
echo $price->textContent . PHP_EOL;
}
【问题讨论】:
标签: php jquery web-scraping guzzle