First time posting here. Just finished my first Python course, so I've been trying to do some web scraping on my own but have failed to do so.
When I run my code I get an empty dictionary, and I don't really understand what should I do. I've been doing some research and it appears that the page I'm trying to scrape uses an AJAX application that maybe requires some other type of technique.
I've noticed that the piece of information that I'm trying to gather (a list of product prices) is under this tag: https://b2b.devir.cl/addmultipleproducts/cart/ajaxaddmultiple
This is my code and the end result is:
200 (which signals the page was accessed correctly as far as I know)
[]
from bs4 import BeautifulSoup as bs
import requests
URL = 'https://b2b.devir.cl/'
LOGIN_ROUTE= 'customer/account/login/'
HEADERS={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36', 'origin':URL, 'referer':URL+LOGIN_ROUTE}
s=requests.session()
front_end=s.get(URL).cookies['frontend']
login_payload = {
'login[username]': 'xxxx',
'login[password]': 'yyyy',
'form_key': front_end
}
login_req = s.post(URL+LOGIN_ROUTE, headers=HEADERS, data=login_payload)
print(login_req.status_code)
cookies=login_req.cookies
r=requests.get(URL+'juegos-de-mesa.html?po_stock=1')
soup=bs(r.content,'lxml')
productlist=[]
productlist=soup.find_all('div', {'class': 'category-products'})
print(productlist)
I would very much appreciate to hear some piece of advice on this, and I'm sorry in advance for my ignorance on the topic.