Giter Club home page Giter Club logo

Comments (7)

jond01 avatar jond01 commented on July 19, 2024

Re-checking now: there's no difference between the scraped and online-viewed JSON, and the test passed.

from xil.

jond01 avatar jond01 commented on July 19, 2024

After checking manually and reviewing the test runs (including the latest run), the issue does not reproduce.
I'm going to close it as a temporary bug.

from xil.

jond01 avatar jond01 commented on July 19, 2024

https://github.com/jond01/xil/actions/runs/6865423605/job/18674728221

from xil.

jond01 avatar jond01 commented on July 19, 2024

https://github.com/jond01/xil/actions/runs/7330517632
https://github.com/jond01/xil/actions/runs/7339447462
https://github.com/jond01/xil/actions/runs/7378131143
https://github.com/jond01/xil/actions/runs/7432286995

from xil.

jond01 avatar jond01 commented on July 19, 2024

The latest run (from today) shows the following difference when accessing through Python and a web browser (Chrome/Firefox/Safari):

{
-    "generatingReportDateTime": "2024-01-05",
+    "generatingReportDateTime": "2024-01-06",
    "marketingRecords": [
        {
            "buyRate": 0.2475,
            "fromCurrency": "EUR",
            "representativeExchangeRate": 0.2505,
            "sellRate": 0.2499,
            "toCurrency": "ILS"
        },
        {
            "buyRate": 4.001,
            "fromCurrency": "ILS",
            "representativeExchangeRate": 3.9917,
            "sellRate": 4.0412,
            "toCurrency": "EUR"
        },
        {
            "buyRate": 0.2698,
            "fromCurrency": "USD",
            "representativeExchangeRate": 0.2735,
            "sellRate": 0.2725,
            "toCurrency": "ILS"
        },
        {
            "buyRate": 3.6691,
            "fromCurrency": "ILS",
            "representativeExchangeRate": 3.656,
            "sellRate": 3.706,
            "toCurrency": "USD"
        }
    ]
}

The later and true date (2023-01-06) is from Python.
A quick test showed that when passing the following "Accept-Encoding" header in Python, the result was the same as in the web:

import urllib.request

headers = {"Accept-Encoding": "gzip, deflate, br"}  # This header makes the server return an outdated response
url = "https://dv16ymfyh91nr.cloudfront.net/MarketingRatesReport/MarketingSiteFCYRatesCurrentReport.json"

req = urllib.request.Request(url, headers=headers)
with urllib.request.urlopen(req) as f:
    print(f.read().decode())
Original check code
import json
import urllib.request
import logging

logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)

all_headers = {
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
    "Accept-Encoding": "gzip, deflate, br",
    "Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
    "Connection": "keep-alive",
    "Host": "dv16ymfyh91nr.cloudfront.net",
    "Priority": "u=0, i",
    "Sec-Fetch-Dest": "document",
    "Sec-Fetch-Mode": "navigate",
    "Sec-Fetch-Site": "none",
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15",
}
url = "https://dv16ymfyh91nr.cloudfront.net/MarketingRatesReport/MarketingSiteFCYRatesCurrentReport.json"

for item in all_headers.items():
    headers = dict([item])
    logger.debug(headers)
    req = urllib.request.Request(url, headers=headers)
    with urllib.request.urlopen(req) as f:
        data = f.read().decode()
    if json.loads(data)["generatingReportDateTime"] == "2024-01-05":
        logger.info("Found it!")

It explains the discrepancy mentioned in the issue's description, but not the failure of the test.

Moreover, since writing this comment, the web browser's response has been updated, matching now Python.
image
image

from xil.

jond01 avatar jond01 commented on July 19, 2024

https://github.com/jond01/xil/actions/runs/7432286995/job/20225973783

The client sub-issue (web browser/Python) is orthogonal to the test failure.
Even when the same, the test may fail, as in the case linked above.
The "buyRate" is higher than the "representativeExchangeRate" for both EUR and USD ("toCurrency").
The fix for the issue is probably to remove the wrong assertion.

from xil.

jond01 avatar jond01 commented on July 19, 2024

https://github.com/jond01/xil/actions/runs/8422210010/job/23060978005#step:6:42

from xil.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.