diff --git a/old/bilibili_login.py b/old/bilibili_login.py deleted file mode 100644 index 3c333bc..0000000 --- a/old/bilibili_login.py +++ /dev/null @@ -1,76 +0,0 @@ -import requests -import re - -'/html/body/div[2]/div/div/div[3]/div[3]/div/div/ul/li[6]/a[1]' -'//*[@id="userId"]' -'//*[@id="passwd"]' -'/html/body/div[1]/div/div[2]/form/div/div[2]/div/p/a[1]' -'//*[@id="email"]' -'/html/body/div/div/div[2]/div/div[2]/div[2]/p/a[1]' -class Bilibili(object): - def __init__(self): - self.session = requests.session() - - def login(self, user, pwd): - """ - .. warning:: - | THE API IS NOT OFFICIAL API - | DETAILS: https://api.kaaass.net/biliapi/docs/ - :param user: username - :type user: str - :param pwd: password - :type pwd: str - :return: if success return True - else return msg json - """ - r = requests.post( - url='https://api.kaaass.net/biliapi/user/login', - data={ - 'user' : user, - 'passwd': pwd - }, - headers={ - 'x-requested-with': 'XMLHttpRequest' - } - - ) - # {"ts":1498361700,"status":"OK","mid":132604873,"access_key":"fb6c52162481d92a20875aca101ebe92","expires":1500953701} - # print(r.text) - if r.json()['status'] != 'OK': - return r.json() - - access_key = r.json()['access_key'] - r = requests.get( - url='https://api.kaaass.net/biliapi/user/sso?access_key=' + access_key, - headers={ - 'x-requested-with': 'XMLHttpRequest' - } - ) - # {"ts":1498361701,"status":"OK","cookie":"sid=4jj9426i; DedeUserID=132604873; DedeUserID__ckMd5=e6a58ccc06aec8f8; SESSDATA=4de5769d%2C1498404903%2Cd86e4dea; bili_jct=5114b3630514ab72df2cb2e7e6fcd2eb"} - # print(r.text) - - if r.json()['status'] == 'OK': - cookie = r.json()['cookie'] - self.session.headers["cookie"] = cookie - self.csrf = re.search('bili_jct=(.*?);', cookie + ';').group(1) - self.mid = re.search('DedeUserID=(.*?);', cookie + ';').group(1) - self.session.headers['Accept'] = 'application/json, text/javascript, */*; q=0.01' - self.session.headers['Referer'] = 'https://space.bilibili.com/{mid}/#!/'.format(mid=self.mid) - # session.headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36' - # session.headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8' - return True - else: - return r.json() - def home_page(self): - home = self.session.get('https://www.bilibili.com/') - page = self.session.get('https://member.bilibili.com/v/video/submit.html') - print(home.headers) - print(page.cookies._cookies) - print(self.session.headers) - -if __name__ == '__main__': - # b = Bilibili() - # b.login('y446970841@163.com', '1122000') - # b.home_page() - response = requests.get('https://member.bilibili.com/v/video/submit.html') - print(response.text) \ No newline at end of file diff --git a/old/get_cookie.py b/old/get_cookie.py deleted file mode 100644 index 3261303..0000000 --- a/old/get_cookie.py +++ /dev/null @@ -1,74 +0,0 @@ -import json -from selenium import webdriver -import time -from selenium.webdriver.chrome.options import Options - -chrome_options = Options() -chrome_options.add_argument("--headless") -driver = webdriver.Chrome(executable_path=r'D:\bilibiliupload\chromedriver.exe', - chrome_options=chrome_options) - -driver = webdriver.Chrome(executable_path=r'D:\bilibiliupload\chromedriver.exe') - -driver.get("https://www.bilibili.com") - -# with open('bilibili.cookie') as f: -# cookies = json.load(f) -# # cookies = [{'name': 'sid', 'value': '97rjjtc1'}, {'name': 'DedeUserID', 'value': '274986200'}, {'name': 'DedeUserID__ckMd5', 'value': '1206e39bc044fe98'}, {'name': 'SESSDATA', 'value': '3e02f3d0%2C1521242566%2Cbd06c98d'}, {'name': 'bili_jct', 'value': '3b092ca1cacc59b2b7679bd997afe5ca'}] -# cookies = bilibili_api.cform('buvid2=52416955-9EB7-46AD-9422-46E2345654E126585infoc; dssid=7bjk90112abbebf8c; dsess=BAh7CkkiD3Nlc3Npb25faWQGOgZFVEkiFTkwMTEyYWJiZWJmOGMzOTkGOwBG%0ASSIJY3NyZgY7AEZJIiVhMTBmMTM2MzkyYWYyOWNiNmQyZTJlNWUxMTMxZTJj%0AZgY7AEZJIg10cmFja2luZwY7AEZ7B0kiFEhUVFBfVVNFUl9BR0VOVAY7AFRJ%0AIi1jYmQyZDYyYTc2MGZjMmViYzk1NDA2MGQ5NGNmZWVkYWFhNDk0YTU1BjsA%0ARkkiGUhUVFBfQUNDRVBUX0xBTkdVQUdFBjsAVEkiLWNhNGFlZTBlODEyMTRh%0AZGRjNWZiMTI4NzdjZjllNWM4YjhiZWI3ZDYGOwBGSSIKY3RpbWUGOwBGbCsH%0AY3cRWkkiCGNpcAY7AEYiEzExNS4xNTUuMTE0Ljk1%0A--b014e84af2e4612099ac4348d29205b2813fd930; fts=1511094141; UM_distinctid=15fdc423182b22-07a38f91352cb7-7b113d-144000-15fdc423183a13; pgv_pvi=3700880384; rpdid=olklsxmolldosooiiqlpw; sid=8k9huzd0; LIVE_BUVID=a23404d890e536c9a93b72e5e50be145; LIVE_BUVID__ckMd5=d5ea746722041186; buvid3=755A6D1D-A15D-40D5-BCEB-F96E5A67F85444996infoc; im_notify_type_274986200=0; finger=edc6ecda; im_seqno_274986200=14; im_local_unread_274986200=0; DedeUserID=274986200; DedeUserID__ckMd5=1206e39bc044fe98; SESSDATA=3e02f3d0%2C1523167736%2C0bbe16f2; bili_jct=11d9ff352f4a89846abebe85daadde3a; pgv_si=s6206720000; _dfcaptcha=0755ca3de2fba71d32605654777511a9') -# print(cookies) -# # driver.delete_all_cookies() -# for cookie in cookies: -# # cookie.pop('domain') -# # print(cookie) -# driver.add_cookie(cookie) -# driver.get("https://www.bilibili.com") -driver.get("https://member.bilibili.com/video/upload.html") - -# WebDriverWait(driver, 10).until( -# EC.presence_of_element_located((By.XPATH, r'/html/body/div[2]/div/div/div[3]/div[3]/div/div/ul/li[6]/a[1]'))) - -# time.sleep(1) -# xl = driver.find_element_by_xpath(r'/html/body/div[2]/div/div/div[3]/div[3]/div/div/ul/li[6]/a[1]') -# xl.click() - -# WebDriverWait(driver, 10).until(JSESSIONID=E9A43CDCEEE9204A5D67180C9E22CF67 -# EC.presence_of_element_located((By.XPATH, r'//*[@id="userId"]'))) - -# time.sleep(2) -username = driver.find_element_by_xpath(r'//*[@id="login-username"]') -username.send_keys('y446970841@163.com') - -password = driver.find_element_by_xpath('//*[@id="login-passwd"]') -password.send_keys('1122000') - -# login = driver.find_element_by_xpath(r'/html/body/div[1]/div/div[2]/form/div/div[2]/div/p/a[1]') -# ActionChains(driver).double_click(login).perform() -# # login.click() -# -# time.sleep(2) -# email = driver.find_element_by_xpath(r'//*[@id="email"]') -# email.click() -# -# loging = driver.find_element_by_xpath(r'/html/body/div/div/div[2]/div/div[2]/div[2]/p/a[1]') -# loging.click() - - - -# driver.save_screenshot('screenshot.png') - -time.sleep(8) - -# driver.save_screenshot('screenshot1.png') - -cookie = driver.get_cookies() -print(cookie) -filename = 'bilibili.cookie' -with open(filename, "w") as f: - json.dump(cookie, f) - -with open(filename) as f: - new_cookie = json.load(f) - -print(new_cookie) -print(type(new_cookie),type([])) diff --git a/old/slider.py b/old/slider.py deleted file mode 100644 index 80b4cfc..0000000 --- a/old/slider.py +++ /dev/null @@ -1,73 +0,0 @@ -import time -from PIL import Image -from selenium.webdriver.common.action_chains import ActionChains - -class slider_cracker(object): - def __init__(self,driver): - self.driver = driver - self.driver.maximize_window() #最大化窗口 - - def get_true_image(self,slider_xpath=r'//*[@id="gc-box"]/div/div[3]/div[1]'): - element = self.driver.find_element_by_xpath(slider_xpath) - ActionChains(self.driver).move_to_element(element).perform()#鼠标移动到滑动框以显示图片 - time.sleep(1) - true_image = self.get_img('true_image.png') - return true_image - - def get_img(self,img_name,img_xpath=r'//*[@id="gc-box"]/div/div[1]/div[2]/div[1]/a[2]'):#260*116 - screen_shot = self.driver.save_screenshot('slider_screenshot.png') - image_element = self.driver.find_element_by_xpath(img_xpath) - left = image_element.location['x'] - top = image_element.location['y'] #selenium截图并获取验证图片location后将其截出保存 - right = image_element.location['x'] + image_element.size['width'] - bottom = image_element.location['y'] + image_element.size['height'] - image = Image.open('slider_screenshot.png') - image = image.crop((left, top, right, bottom)) - image.save(img_name) - return image - - def analysis(self,true_image,knob_xpath=r'//*[@id="gc-box"]/div/div[3]/div[2]'): - img1 = Image.open('true_image.png') - slider_element = self.driver.find_element_by_xpath(knob_xpath) - ActionChains(self.driver).click_and_hold(slider_element).perform() #点击滑块后截取残缺图 - img2 = self.get_img('img2.png') - img1_width,img1_height = img1.size - img2_width,img2_height = img2.size - left = 0 - flag = False - - for i in range(65, img1_width): #遍历x>65的像素点(x<65是拼图块) - for j in range(0,img1_height): - if not self.is_pixel_equal(img1, img2, i, j): - left = i - flag = True - break - if flag: - break - - left = left-5 #误差纠正 - return left - - def is_pixel_equal(self, img1, img2, x, y): #通过比较俩图片像素点RGB值差值判断是否为缺口 - pix1 = img1.load()[x, y] - pix2 = img2.load()[x, y] - if (abs(pix1[0] - pix2[0] < 60) and abs(pix1[1] - pix2[1] < 60) and abs(pix1[2] - pix2[2] < 60)): - return True - else: - return False - - def drag_and_drop(self, x_offset=0, y_offset=0, knob_xpath=r'//*[@id="gc-box"]/div/div[3]/div[2]'): - - knob_element = self.driver.find_element_by_xpath(knob_xpath) - ActionChains(self.driver).drag_and_drop_by_offset(knob_element, x_offset, y_offset).perform()#拉动滑块 - time.sleep(2) - - def crack(self): - true_image = self.get_true_image() - x_offset = self.analysis(true_image) - print(x_offset) - self.drag_and_drop(x_offset=x_offset,y_offset=30) #30为随便加的 - - - - diff --git a/old/weibo.py b/old/weibo.py deleted file mode 100644 index b370b3b..0000000 --- a/old/weibo.py +++ /dev/null @@ -1,15 +0,0 @@ -from selenium import webdriver - - - -driver = webdriver.Chrome(executable_path=r'D:\bilibiliupload\chromedriver.exe') - -driver.get("https://api.weibo.com/oauth2/authorize?client_id=2841902482&redirect_uri=https://passport.bilibili.com/login/snsback?sns=weibo&state=2a4055b02e5411e881f60242ac123e5a&scope=email") - -cookie = {'name': 'JSESSIONID', 'value': 'E9A43CDCEEE9204A5D67180C9E22CF67'} - -driver.add_cookie(cookie) - -driver.get('https://api.weibo.com/oauth2/authorize') - -