как получить доступ к лучшей цене товара - PullRequest
0 голосов
/ 02 ноября 2019

Я хочу проверить цену товара на сайте BestBuy, однако доступ запрещен. У кого-нибудь есть совет, как получить доступ? Спасибо!

Мой код:

import requests
import bs4 as bs 

url = "https://www.bestbuy.com/site/lg-65-class-oled-b9-series-2160p-smart-4k-uhd-tv-with-hdr/6360611.p?skuId=6360611"
url_get = requests.get(url)
soup = bs.BeautifulSoup(url_get.content, 'lxml')

with open('url_bestbuy.txt', 'w', encoding='utf-8') as f_out:
    f_out.write(soup.prettify())

js_test = soup.find('span', id ='priceblock_ourprice') 
if js_test is None: 
    js_test = soup.find('span', id ='div.price-block')         
str = "" 
for line in js_test.stripped_strings : 
    str = line 

# convert to integer 
str = str.replace(", ", "") 
str = str.replace("$", "") 

current_price = int(float(str)) 
your_price = 2000
if current_price < your_price : 
    print("I can afford it") 
else: 
    print("Price is high please wait for the best deal") 

У вас нет прав для доступа "http://www.bestbuy.com/site/lg-65-class-oled-b9-series-2160p-smart-4k-uhd-tv-with-hdr/6360611.p?" на этом сервере.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...