-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
32 lines (22 loc) · 960 Bytes
/
test.py
File metadata and controls
32 lines (22 loc) · 960 Bytes
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
32
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
import re as re
if __name__ == '__main__':
_input = "moto g84 5g"
_input = re.sub(r'\s+', '+' , _input)
URL = 'https://www.flipkart.com/search?q=' + _input
# Initialize Selenium WebDriver
options = webdriver.ChromeOptions()
options.add_argument('--headless') # Run in headless mode (without opening the browser window)
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
# Replace the executable path with the path to your chromedriver
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
# Visit the URL
driver.get(URL)
# Get page content
page_content = driver.page_source
print(page_content) # Optional: to check the loaded HTML
# Close the browser
driver.quit()