-
Notifications
You must be signed in to change notification settings - Fork 0
/
selenium_request_test.py
35 lines (31 loc) · 1.08 KB
/
selenium_request_test.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
32
33
34
35
from selenium import *
from selenium import webdriver
from selenium.webdriver import Firefox
import threading
import time
import re
def get_praise():
browser = Firefox(executable_path=r'C:\Program Files\Mozilla Firefox\geckodriver.exe')
browser.get("https://www.google.com/search?q=Lenovo IdeaPad 330")#.format(object_p)
results = browser.find_elements_by_css_selector('div.g')
href = []
for result in results:
link = result.find_element_by_tag_name("a")
href.append(link.get_attribute("href"))
iterator =0
print(len(href))
list_price = []
for link in href:
try:
#time.sleep(5)
browser.execute_script("window.open('');")
browser.switch_to.window(browser.window_handles[iterator]) # Switch to the new window
print(link)
browser.get(link)
print(browser.find_elements_by_css_selector('div'))
iterator+=1
except:
print("Error: unable to start thread")
#object_p = input()
print(list_price)
get_praise()