You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TbbcMoneyBundle ratio_provider失效求助:Google汇率获取报错

Fix "The current node list is empty" Error in TbbcMoneyBundle's tbbc:money:ratio-fetch Command

I’ve dealt with this exact issue before — the root cause is Google Finance updating its page structure, which breaks the HTML scraping logic built into the bundle’s Google ratio provider. The crawler is looking for specific HTML elements that no longer exist on Google’s site, hence the empty node list error from Crawler.php.

Here are the most practical fixes to get your currency ratios fetching again:

1. Switch to the Yahoo Finance Ratio Provider

The bundle includes a Yahoo Finance provider that’s more reliable these days (less prone to sudden HTML structure changes). Update your configuration to use it instead:

tbbc_money:
  currencies: ["UAH", "USD", "EUR", "PLN"]
  reference_currency: "USD"
  decimals: 2
  storage: doctrine
  ratio_provider: tbbc_money.ratio_provider.yahoo_finance
  # Comment out the Google provider line
  # ratio_provider: tbbc_money.ratio_provider.google

Save the config, then re-run the command:

bin/console tbbc:money:ratio-fetch

This should resolve the error unless Yahoo’s API structure has also changed (though it’s held up better than Google’s scraper targets).

2. Build a Custom Ratio Provider (For Long-Term Stability)

If you need a more robust solution, consider using a dedicated currency API like Open Exchange Rates (free tier available for limited use). Here’s a quick breakdown:

  • Create a custom class that implements Tbbc\MoneyBundle\Pair\RatioProviderInterface
  • In the class, make an HTTP request to your chosen API, parse the response, and return the required currency ratios
  • Register your class as a Symfony service, then update the ratio_provider config to point to your service ID

This approach avoids fragile HTML scraping entirely, making your setup less likely to break in the future.

3. Patch the Google Provider’s Crawler Logic (If You Must Use Google)

If you’re set on using Google Finance, you’ll need to update the crawler selectors in the bundle’s GoogleRatioProvider class:

  1. Locate the class in your vendor directory (or fork the repository to make safe, maintainable changes)
  2. Visit Google Finance’s currency page for your target pairs (e.g., USD to EUR)
  3. Use your browser’s dev tools to find the new HTML selector for the exchange rate value
  4. Update the fetchRatio method in GoogleRatioProvider to use the new selector instead of the outdated one

For example, if the old code used $crawler->filter('.FxKbKc')->text(), replace that selector with the current one you identified in dev tools.

After making the change, clear your Symfony cache and re-run the command.


内容的提问来源于stack exchange,提问作者Dziblyuk Andriy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:48:25