Closed JamesOsborn-SE closed 8 months ago
I have a few accounts with data in 2023, so that can't be it. Without an example page, it's going to be difficult for me to help resolve the issue. However, my page has both order-card
and js-order-card
.
There is a variable in orders.py
named ORDER_HISTORY_CARD_SELECTOR
, that selects the div. It defaults to div[class*='order-card']:has(script)
. Try changing its value from your code (before you instantiate an AmazonOrders
class) to div[class*='js-order-card']:has(script)
instead.
Also, can you try passing debug=True
when instantiating AmazonSession
and AmazonOrders
? I wonder if that'll show us anything interesting.
I can try to sanitize the HTML. I tried the above, but the result was the same. If I get rid of :has(script)
it spits out a bunch of parsing errors but gets the orders and the items.
example of a parsing error:
When building Order, `recipient` could not be parsed.
Traceback (most recent call last):
File "/home/james/repos/amazon-orders-to-csv/venv/lib/python3.11/site-packages/amazonorders/entity/parsable.py", line 38, in safe_parse
return parse_function()
^^^^^^^^^^^^^^^^
File "/home/james/repos/amazon-orders-to-csv/venv/lib/python3.11/site-packages/amazonorders/entity/order.py", line 139, in _parse_recipient
id=lambda value: value and value.startswith("shipToInsertionNode")).attrs[
^^^^^
AttributeError: 'NoneType' object has no attribute 'attrs'
I have seen that error before, when I switched from using the find()
method to the select()
method. When I did that, I actually saw two of every order on the page—I believe one comes from the Githubissues.
Acknowledgements
debug
mode and am attaching relevant console logs and HTML filesOperating System
EndeavourOS
Python Version
3.11
amazon-orders Version
1.0.6
Describe the Bug
The above prints
[]
I wrote the file out in theget_orders_history/orders.py
It looks like the expected HTML is very different from what it gets back. There is no "order-card" but there is a "js-order-card"
I've not use beautiful soup much, so I'm not familiar with the selector stuffs.
FYI, PyPI only has version 1.0.4
Steps to Reproduce
Run code with an account that has orders in 2023.
Expected Behavior
To pull all the orders from 2023