Beispiel #1
0
from selenium import webdriver
import sys
import time
import dbhelper
from video import *
from selenium.common.exceptions import NoSuchElementException


driver = webdriver.Chrome("chromedriver.exe")
# 数据库连接
conn, c = dbhelper.connect_db()

if len(sys.argv) < 3:
    start_id = 12872143
    end_id = 12972143
else:
    start_id = int(sys.argv[1])
    end_id = int(sys.argv[2])
    print("Start_ID:",sys.argv[1])
    print("End_ID:",sys.argv[2])

base_url = "URL:Hidden"

i = 0
while (start_id+i)<end_id:
    driver.get(base_url + str(start_id + i))
    
    try:
        video = driver.find_element_by_id("post_video")
    except NoSuchElementException as msg:
        print("ID:",str(start_id + i)," | 非视频页面!")
def connect_to_db():
    conn, c = dbhelper.connect_db()
    return conn, c