Skip to content
This repository was archived by the owner on Apr 2, 2023. It is now read-only.

Commit cf9a669

Browse files
committed
Fix Raffle Items Scrape
- Changed regex to get the raffle products Note: If it breaks again, i'll just switch to BS4
1 parent 59c5c28 commit cf9a669

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

newegg/submit_raffle/raffles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
def get_items():
88
temp = []
9+
s = requests.Session()
910
while True:
1011
try:
11-
s = requests.Session()
1212
res = s.get("https://www.newegg.com/product-shuffle")
13-
raffle_products = json.loads(re.findall(r"{.+[:,].+}", res.text)[1].split("</script>")[0])
13+
raffle_products = json.loads(re.findall(r"(?<=window\.__initialState__[^{]\S.)(.*?)(?=<\/script>)", res.text)[0])
1414
for products in raffle_products["lotteryData"]["LotteryItems"]:
1515
for raffle_item in products["ChildItem"]:
1616
# Get the item(s) in the combo

0 commit comments

Comments
 (0)