|
@@ -41,7 +41,7 @@ def re_get_webdriver():
|
|
|
options = webdriver.ChromeOptions()
|
|
|
options.add_argument("--no-sandbox")
|
|
|
options.add_argument("--disable-dev-shm-usage")
|
|
|
- options.add_argument("--headless")
|
|
|
+# options.add_argument("--headless")
|
|
|
|
|
|
print(user_agent)
|
|
|
# options.add_argument("--user-agent=" +user_agent)
|
|
@@ -55,7 +55,8 @@ def re_get_webdriver():
|
|
|
os.system('kill %d' % os.getpid())
|
|
|
sys.exit()
|
|
|
return
|
|
|
- driver.set_window_size(1400,1000)
|
|
|
+# driver.set_window_size(1400,1000)
|
|
|
+ driver.minimize_window()
|
|
|
return
|
|
|
except:
|
|
|
import traceback
|
|
@@ -70,7 +71,7 @@ def from_shopping(kw):
|
|
|
driver.get('https://shopping.google.com')
|
|
|
time.sleep(5)
|
|
|
elmt = driver.find_element(By.XPATH, "//input[@id='REsRA']")
|
|
|
- elmt.send_keys('幸福空間')
|
|
|
+ elmt.send_keys(kw)
|
|
|
elmt.send_keys(Keys.ENTER) #hits space
|
|
|
time.sleep(7)
|
|
|
elmt = driver.find_element(By.XPATH, "//div[@class='hdtb-mitem']/a[contains(text(),'全部') or contains(text(),'All')]")
|
|
@@ -83,7 +84,7 @@ def from_book(kw):
|
|
|
driver.get('https://books.google.com/')
|
|
|
time.sleep(5)
|
|
|
elmt = driver.find_element(By.XPATH, "//input[@id='oc-search-input']")
|
|
|
- elmt.send_keys('幸福空間')
|
|
|
+ elmt.send_keys(kw)
|
|
|
elmt.send_keys(Keys.ENTER) #hits space
|
|
|
time.sleep(7)
|
|
|
elmt = driver.find_element(By.XPATH, "//div[@class='hdtb-mitem']/a[contains(text(),'全部') or contains(text(),'All')]")
|
|
@@ -187,6 +188,7 @@ def from_ekoru(kw):
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
def from_yahoo(kw):
|
|
|
global driver
|
|
|
driver.get('https://search.yahoo.com/search?p=google')
|
|
@@ -222,12 +224,23 @@ def from_gibiru(kw):
|
|
|
time.sleep(6)
|
|
|
|
|
|
|
|
|
+def from_google(kw):
|
|
|
+ global driver
|
|
|
+ driver.get('https://www.google.com?num=30')
|
|
|
+ print(kw)
|
|
|
+ time.sleep(4)
|
|
|
+ elmt = driver.find_element(By.XPATH, "//input[@name='q']")
|
|
|
+ time.sleep(1)
|
|
|
+ elmt.send_keys(kw)
|
|
|
+ elmt.send_keys(Keys.ENTER)
|
|
|
+ time.sleep(6)
|
|
|
|
|
|
def run_once(jsobj):
|
|
|
global driver
|
|
|
|
|
|
|
|
|
i=random.randint(0,9)
|
|
|
+ i=10
|
|
|
if driver is None:
|
|
|
time.sleep(8)
|
|
|
re_get_webdriver()
|
|
@@ -263,6 +276,8 @@ def run_once(jsobj):
|
|
|
from_ecosia(kw)
|
|
|
elif i==9:
|
|
|
from_brave(kw)
|
|
|
+ else:
|
|
|
+ from_google(kw)
|
|
|
# time.sleep(9999)
|
|
|
elmts = driver.find_elements(By.XPATH, "//div[@class='yuRUbf']/a")
|
|
|
|