我想复制Luno的ZAR / BTC汇率。
class ParallelReportDownload {
// Timeout between retries in seconds.
const BACKOFF_FACTOR = 5;
// Maximum number of retries for 500 errors.
const MAX_RETRIES = 5;
// The number of entries per page of the results.
const PAGE_LIMIT = 500;
public static function runExample(AdWordsServices $adWordsServices,
AdWordsSessionBuilder $sessionBuilder, $reportDir) {
// Construct an API session for the client customer ID specified in the
// configuration file.
$session = $sessionBuilder->build();
// Create selector.
$selector = new Selector();
$selector->setFields(['Month', 'Impressions', 'Clicks', 'Ctr', 'AverageCpc', 'AveragePosition', 'Cost', 'Conversions', 'CostPerConversion', 'ConversionRate', 'SearchImpressionShare']);
//THIS CODE WAS FOUND ON GOOGLE API FORUM
$selector->dateRange = new DateRange();
$selector->dateRange->min = date('Ymd', strtotime('2017/06/01'));
$selector->dateRange->max = date('Ymd', strtotime('2017/06/09'));
// Use a predicate to filter out paused criteria (this is optional).
//$selector->setPredicates([
//new Predicate('Impressions', PredicateOperator::GREATER_THAN, [1000]),
//new Predicate('CampaignName', PredicateOperator::CONTAINS, ['Branded'])
//]);
// Create report definition.
$reportDefinition = new ReportDefinition();
$reportDefinition->setSelector($selector);
$reportDefinition->setReportName('LAST_MONTH ACCOUNT_PERFORMANCE_REPORT');
$reportDefinition->setDateRangeType(
ReportDefinitionDateRangeType::CUSTOM_DATE);
$reportDefinition->setReportType(
ReportDefinitionReportType::ACCOUNT_PERFORMANCE_REPORT);
$reportDefinition->setDownloadFormat(DownloadFormat::CSV);
$customerIds = self::getAllManagedCustomerIds($adWordsServices, $session);
printf("Downloading reports for %d managed customers.\n",
count($customerIds));
$successfulReports = [];
$failedReports = [];
foreach ($customerIds as $customerId) {
$filePath = "../../../../../../clients/client_reports/accounts/" . $customerId . "_LAST_MONTH___account.csv";
这是我正在使用的代码,但字符串包含整个页面源,这不是问题本身。问题是在ZAR中应该有BTC的价格,有一个名为" FormatPrice()"而不是价格。
但我可以简单地突出显示实际网站上的价格并复制和粘贴。我有什么方法可以做到这一点吗?
提前致谢。
答案 0 :(得分:1)
简短回答是否定的,您不能:下载网站的HTML内容实际上并不执行修改其UI和数据的所有Javascript更改。
请注意,您定位的网站has an API you can use可获取其数据。这是做你需要的正确方法。