from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class selenium_nign():
def __init__(self,url=''):
self.url = url
driver = webdriver.FirefoxOptions()
driver.add_argument('-headless')
self.driver =webdriver.Firefox(firefox_options=driver)
# driver=webdriver.Firefox()
self.driver.get(self.url)
def nign(self,time=0):
nign =self.driver.execute_script('''return TAC.sign(108888017311+''+'''+str(time)+''')''')
#通过这里来获取,第一个参数为作者id,第二个参数就是前面讲的max_behot_time参数
return nign
def cookie(self,blok=0):
#这里获取cookie,头条对id也有加密,正常的session获取的会话似乎没办法通过
if blok:
self.driver.get(self.url)
cookies = self.driver.get_cookies()
cookie =[item['name'] + "=" + item['value'] for item in cookies]
cookiestr ='; '.join(item for item in cookie)
return cookiestr
def sclock(self):
self.driver.close()