Answer the question
In order to leave comments, you need to log in
Python. I can't parse the price tag in the "DNS" store. Can you help?
import requests
from bs4 import BeautifulSoup
def get_html(url):
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
r = requests.get(url, headers = headers)
return r.text
def get_elements(html, tag, class_name):
soup = BeautifulSoup(html, 'html.parser')
pages = soup.find_all(tag, class_= class_name)
return pages
class DNS():
html = get_html('https://www.dns-shop.ru/catalog/17a899cd16404e77/processory/order=1&groupBy=none&brand=amd&stock=2')
price = get_elements(html, 'div', 'product-min-price__current')
print(price)
DNS()
Answer the question
In order to leave comments, you need to log in
Discover postman. It is a handy tool for making queries. And in it send a request to the link that you have. I don’t have the opportunity to check right now, but I think that JS is running on the page, which fills the page with the data you need, and in the python script you get raw data, without executing JS.
Read about selenium, it will help in such cases. Or study what requests the site sends and simulate them.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question