123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- import time
- import traceback
- from selenium import webdriver
- from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
- import time
- import urllib
- import os
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support import expected_conditions as EC
- import dataset
- from selenium.webdriver.common.keys import Keys
- import json
- import random
- import time
- import redis
- import sys
- import codecs
- import random
- import os
- import time
- import requests
- import datetime
- driver=None
- from fake_useragent import UserAgent
- ua = UserAgent()
- def re_get_webdriver():
-
- global driver
- global portnum
-
- result=[]
-
-
-
-
-
-
- options = webdriver.ChromeOptions()
- options.add_argument("--user-agent=" +ua.random)
- options.add_argument("--no-sandbox")
- options.add_argument("--headless")
- options.add_argument("--incognito")
- driver = webdriver.Remote(
- command_executor='http://127.0.0.1:'+str(portnum)+'/wd/hub',
- options=options)
- return driver
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- def run_once():
- global count
- global portnum
- global bok
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ettoday_url_list = ['https://house.ettoday.net/news/1492047',
- 'https://house.ettoday.net/news/1492167',
- 'https://house.ettoday.net/news/1492288',
- 'https://house.ettoday.net/news/1492178',
- 'https://house.ettoday.net/news/1492229',
- 'https://house.ettoday.net/news/1492134',
- 'https://house.ettoday.net/news/1492240',
- 'https://house.ettoday.net/news/1492161',
- 'https://house.ettoday.net/news/1492168',
- 'https://house.ettoday.net/news/1492217']
-
-
- for i in ettoday_url_list:
- try:
- driver=re_get_webdriver()
- except:
- portnum=random.randint(4555,4666)
- print(portnum)
- os.system('docker container stop p8816')
- time.sleep(5)
- os.system('docker container rm p8816')
- time.sleep(5)
- os.system('docker run -d -p '+str(portnum)+':4444 --name p8816 --dns 168.95.1.1 selenium/standalone-chrome:101.0')
- bok += 1
- count=0
- time.sleep(5)
- driver=re_get_webdriver()
- time.sleep(3)
- try:
- driver.get(i)
- time.sleep(3)
- elmt_next = driver.find_element(By.XPATH, '//*[@id="house"]/div[3]/div[2]/div[6]/div/div/div[1]/article/div/div[3]/p[1]/a')
- webdriver.ActionChains(driver).move_to_element(elmt_next).perform()
- time.sleep(3)
- webdriver.ActionChains(driver).move_to_element(elmt_next).click().perform()
- print("cick!",i)
- count+=1
- print("count_time:",count,';borken_time:',bok)
-
- time.sleep(random.randint(3,7))
- driver.quit()
- except:
- driver.quit()
- print("wrong",i,';borken_time:',bok)
- time.sleep(5)
-
-
-
-
-
-
-
-
-
-
-
-
- portnum=random.randint(4555,4666)
- print(portnum)
- os.system('docker container stop p8816')
- time.sleep(5)
- os.system('docker container rm p8816')
- time.sleep(5)
- os.system('docker run -d -p '+str(portnum)+':4444 --name p8816 --dns 168.95.1.1 selenium/standalone-chrome:101.0')
- bok = 0
- count=0
- time.sleep(5)
- while True:
-
-
- run_once()
|