-
Notifications
You must be signed in to change notification settings - Fork 44
/
amazon_unblocked.py
31 lines (24 loc) · 1.05 KB
/
amazon_unblocked.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import requests
import bs4
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
url = "https://www.amazon.com/Bose-QuietComfort-45-Bluetooth-Canceling-Headphones/dp/B098FKXT8L"
custom_headers = {
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
"accept-language": "en-US,en;q=0.9",
}
proxies = {
"http": "http://USERNAME:[email protected]:60000",
"https": "http://USERNAME:[email protected]:60000",
}
response = requests.get(url, proxies=proxies, verify=False, headers=custom_headers)
if response.status_code != 200:
print("Error: ", response.status_code)
print(response.text)
exit(-1)
soup = bs4.BeautifulSoup(response.text, "lxml")
product_title = soup.find("span", id="productTitle")
print(product_title.getText())
price_element = soup.select_one("div[role='radio'] [class='a-price-whole']")
if price_element:
print(price_element.getText())