chore
This commit is contained in:
parent
20e470eb4d
commit
bd6f45fb3d
@ -1,4 +1,7 @@
|
||||
from selenium import webdriver
|
||||
from utils.config import get_config
|
||||
|
||||
config = get_config()
|
||||
|
||||
|
||||
def setup_driver(proxy=None):
|
||||
|
@ -48,13 +48,7 @@ async def get_channels_by_fofa(callback):
|
||||
|
||||
async def process_fofa_channels(fofa_url, fofa_urls_len):
|
||||
try:
|
||||
flag = retry_func(lambda: driver.get(fofa_url), name=fofa_url)
|
||||
if not flag:
|
||||
driver.quit()
|
||||
if config.open_proxy:
|
||||
proxy = await get_proxy(fofa_url, best=True, with_test=True)
|
||||
driver = setup_driver(proxy)
|
||||
driver.get(fofa_url)
|
||||
retry_func(lambda: driver.get(fofa_url), name=fofa_url)
|
||||
fofa_source = re.sub(r"<!--.*?-->", "", driver.page_source, flags=re.DOTALL)
|
||||
urls = set(re.findall(r"https?://[\w\.-]+:\d+", fofa_source))
|
||||
|
||||
|
@ -13,8 +13,6 @@ from utils.retry import (
|
||||
)
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
import re
|
||||
from bs4 import BeautifulSoup
|
||||
from tqdm.asyncio import tqdm_asyncio
|
||||
|
||||
config = get_config()
|
||||
@ -57,18 +55,6 @@ def search_submit(driver, name):
|
||||
driver.execute_script("arguments[0].click();", submit_button)
|
||||
|
||||
|
||||
async def reset_driver(driver, url):
|
||||
"""
|
||||
Reset the driver
|
||||
"""
|
||||
driver.quit()
|
||||
proxy = None
|
||||
if config.open_proxy:
|
||||
proxy = await get_proxy(url, best=True, with_test=True)
|
||||
driver = setup_driver(proxy)
|
||||
return driver
|
||||
|
||||
|
||||
async def get_channels_by_online_search(names, callback):
|
||||
"""
|
||||
Get the channels by online search
|
||||
@ -86,10 +72,7 @@ async def get_channels_by_online_search(names, callback):
|
||||
async def process_channel_by_online_search(name):
|
||||
info_list = []
|
||||
try:
|
||||
flag = retry_func(lambda: driver.get(pageUrl), name=f"online search:{name}")
|
||||
if not flag:
|
||||
driver = await reset_driver(pageUrl, driver)
|
||||
driver.get(pageUrl)
|
||||
retry_func(lambda: driver.get(pageUrl), name=f"online search:{name}")
|
||||
search_submit(driver, name)
|
||||
isFavorite = name in config.favorite_list
|
||||
pageNum = (
|
||||
@ -132,7 +115,6 @@ async def get_channels_by_online_search(names, callback):
|
||||
)
|
||||
)
|
||||
if next_page_link:
|
||||
driver = await reset_driver(driver, pageUrl)
|
||||
search_submit(driver, name)
|
||||
continue
|
||||
for result in results:
|
||||
|
Loading…
x
Reference in New Issue
Block a user