Update scrap.py
Browse files
scrap.py
CHANGED
@@ -1,17 +1,30 @@
|
|
1 |
import time
|
|
|
2 |
from selenium.webdriver import Chrome
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
from selenium.webdriver.common.by import By
|
4 |
|
5 |
def extract(link):
|
6 |
url = link
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
11 |
data = data.text
|
12 |
data = data.split("\n")
|
13 |
time.sleep(2)
|
14 |
return data
|
15 |
|
16 |
-
ss = extract("https://www.amazon.com/dp/B09B9TB61G?th=1")
|
17 |
-
print(ss)
|
|
|
1 |
import time
|
2 |
+
from selenium import webdriver
|
3 |
from selenium.webdriver import Chrome
|
4 |
+
from selenium.common.exceptions import TimeoutException
|
5 |
+
from selenium.webdriver.common.by import By
|
6 |
+
from selenium.webdriver.firefox.options import Options
|
7 |
+
from selenium.webdriver.firefox.service import Service
|
8 |
+
from selenium.webdriver.support import expected_conditions as EC
|
9 |
+
from selenium.webdriver.support.ui import WebDriverWait
|
10 |
+
from webdriver_manager.firefox import GeckoDriverManager
|
11 |
from selenium.webdriver.common.by import By
|
12 |
|
13 |
def extract(link):
|
14 |
url = link
|
15 |
+
firefoxOptions = Options()
|
16 |
+
firefoxOptions.add_argument("--headless")
|
17 |
+
service = Service(GeckoDriverManager().install())
|
18 |
+
driver = webdriver.Firefox(
|
19 |
+
options=firefoxOptions,
|
20 |
+
service=service,
|
21 |
+
)
|
22 |
+
driver.get(url)
|
23 |
+
data = driver.find_element(By.ID,"aplus_feature_div")
|
24 |
data = data.text
|
25 |
data = data.split("\n")
|
26 |
time.sleep(2)
|
27 |
return data
|
28 |
|
29 |
+
# ss = extract("https://www.amazon.com/dp/B09B9TB61G?th=1")
|
30 |
+
# print(ss)
|