主頁 > 後端開發 > 關于微信小程式爬蟲關于token自動更新問題

關于微信小程式爬蟲關于token自動更新問題

2021-09-26 17:18:17 後端開發

  現在很多的app都很喜歡在微信或者支付寶的小程式內做開發,畢竟比較方便、安全、有流量、不需要再次下載app,好多人會因為加入你讓他下載app他會扭頭就走不用你的app,畢竟做類似產品的不是你一家,

  之前做過很多微信小程式的爬蟲任務,今天做下記錄,防止很久不用后就會忘記,微信小程式分為兩大類:

  1、是不需要登錄的(這種的話不做分析,畢竟沒什么反爬)

  2、需要登錄的

    2.1 登錄一次之后token永久有效

    2.2 登錄一次token幾分鐘內到幾小時內失效

      2.2.1 登錄后一段時間后token時候需要再次呼叫微信內部方法生成code去換取token(本次主要做的)

      2.2.2 跟2.2.1類似,然后又加了一道校驗,比如圖片驗證碼,這個類似于微信公眾號的茅臺預約那種(本次不做分析)

  微信小程式的登錄其實跟其他的web登錄不太一樣,一般的web登錄或者是app登錄基本上就是用戶名+密碼+驗證碼(圖片或者短信)就可以,微信的邏輯是假如你需要登錄的話需要獲得用戶的授權,之后呼叫微信的內部方法生成一個code,code只能用一次之后就實效,微信解釋這個code有效期是5分鐘左右,

  這里是具體流程:https://developers.weixin.qq.com/community/develop/doc/000c2424654c40bd9c960e71e5b009?highLine=code

  之前爬取過的一個小程式他的反爬是token有效期一個小時,然后單次token可用大概100次左右,當單個token使用次數或者單小時內使用次數超過100次就直接封號處理,24小時內也有頻率控制,所以就需要我每小時一次每小時一次的去獲取token,當然,因為我是個程式猿,所以我不能每小時手動的去獲取這個token,比較這不是我們的風格,

  這里需要的是python+fiddler+appium+模擬器,大致的思路是通過appium去操控模擬器模擬點擊微信的小程式,定期的去做點擊,然后fiddler去從請求的頭部資訊中獲取到token,之后寫到本地檔案中,然后python程式定時的去判斷這個本地檔案是否進行了更新,更新了的話通過正則來獲取到token_list之后去最后一個,因為有可能是當前保存的token已經失效了,小程式還會再次去拿這個token嘗試請求一下,假如失效了會呼叫微信的內部方法生成code來換取token,我這里的爬蟲主代碼是運行在服務器的,所有又增加了Redis來存盤token,

  一、微信模擬點擊

  微信按照需求條件時間頻率模擬點擊、滑動、退出等操作,以下的ding_talk的send_msg是增加的釘釘發送訊息,此處不再添加,有需求的可以自己查看釘釘機器人檔案或者依據自己的需求調整自己的訊息提醒,

import time
import logging

from appium import webdriver
from ding_talk import send_msg
from handle_file import EnToken
from conf.dbr import RedisClient
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from config import *

LOG_FORMAT = "%(asctime)s - %(levelname)s - line:%(lineno)s - msg:%(message)s"
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
# logging.FileHandler(filename='app.log', encoding='utf-8')


# 微信獲取en token
class WeChat(object):
    def __init__(self):
        """
        初始化
        """
        # 驅動配置
        self.desired_caps = {
            'platformName': PLATFORM,
            'deviceName': DEVICE_NAME,
            'appPackage': APP_PACKAGE,
            'appActivity': APP_ACTIVITY,
            'noReset': True
        }
        self.driver = webdriver.Remote(DRIVER_SERVER, self.desired_caps)
        self.wait = WebDriverWait(self.driver, TIMEOUT)
        self.hours_en = 60 * 60 * 1.1  # en控制1.1小時模擬點擊一次
        self.date_start_en = time.time()  # en開始時間
        self.date_end_en = 0  # en超過此時間后再次運行
        # self.date_end_en = self.date_start_en + self.hours_en  # en超過此時間后再次運行
        self.week = 60 * 60 * 24 * 7  # 按照周的頻率對xd進行token更新
        self.week_start_xd = time.time()  # xd的開始時間
        self.week_end_xd = 0  # 根據周控制頻率控制再次開啟時間
        self.week_start_xiu = time.time()  # xd的開始時間
        self.week_end_xiu = 0  # 根據周控制頻率控制再次開啟時間

    def login(self):
        """
        登錄微信
        :return:
        """
        # 登錄按鈕
        a = time.time()
        try:
            login = self.wait.until(EC.presence_of_element_located((By.ID, 'com.tencent.mm:id/f34')))
            login.click()
        except Exception as e:
            # print(e)
            logging.info(f'failed login {e}')
        b = time.time() - a
        # print('點擊登錄', b)
        logging.info(f'click login,use time {b}')
        # 手機輸入
        try:
            phone = self.wait.until(EC.presence_of_element_located((By.ID, 'com.tencent.mm:id/bem')))
            phone.set_text(USERNAME)
        except Exception as e:
            # print(e)
            logging.info(f'something wrong{e}')
        c = time.time() - a - b
        # print('手機號輸入', c)
        logging.info(f'send keys phone nums use time {c}')
        # 下一步
        try:
            next = self.wait.until(EC.element_to_be_clickable((By.ID, 'com.tencent.mm:id/dw1')))
            next.click()
        except Exception as e:
            logging.info(f'something wrong{e}')
        d = time.time() - a - b - c
        logging.info(f'click next bottom use time {c}')
        # 密碼
        password = self.wait.until(EC.presence_of_element_located((By.XPATH, '//*[@text="請填寫微信密碼"]')))
        password.set_text(PASSWORD)
        e = time.time() - a - b - c - d
        logging.info(f'send keys password use time {e}')
        # 提交
        # submit = self.wait.until(EC.element_to_be_clickable((By.ID, 'com.tencent.mm:id/dw1')))
        submit = self.wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@text="登錄"]')))
        submit.click()
        f = time.time() - a - b - c - d - e
        logging.info(f'commit password use time {f}')

    def run(self):
        """
        入口
        :return:
        """
        # 滑動之后等待出現en小程式
        self.slide_down()
        time.sleep(10)
        # 點擊進入en小程式

        self.touch_en()
        if self.week_end_xd < self.week_start_xd:
            self.week_start_xd = time.time()
            self.week_end_xd = self.week_start_xd + self.week
            print('xd點擊')
            self.touch_xd()

        elif self.week_end_xiu < self.week_start_xiu:
            self.week_end_xiu = time.time() + self.week
            print('xiu')
            self.touch_xiu()

        time.sleep(10)
        # 退出小程式
        self.driver_closed()
        print('driver closed')
        emt = EnToken()
        token_res = emt.token_2_redis()
        if not token_res:
            print('需要發送失敗訊息')
            return False
        return True

    def slide_down(self):
        """
        滑動微信螢屏之后點擊小程式
        :return:
        """
        window_size_phone = self.driver.get_window_size()
        # print(window_size_phone)
        phone_width = window_size_phone.get('width')
        phone_height = window_size_phone.get('height')
        # print(phone_width, phone_height)
        time.sleep(15)
        x1 = phone_width * 0.5
        y1 = phone_height * 0.7
        y2 = phone_height * 0.26
        # print('準備向下滑動')
        logging.info(f'prepare slide down')
        a = time.time()
        self.driver.swipe(x1, y2, x1, y1, 2050)
        # print('向下滑動完成', time.time() - a)
        logging.info(f'slide down success use time {time.time() - a}')

    def touch_en(self):
        """
        每次進來之后都需要判斷是否到了時間,若時間到了之后才可執行點擊操作
        :param : en 代表en; xd 代表xd; xiu 代表xiu.
        :return: None 無回傳值
        """
        print(self.date_end_en, time.time())
        if self.date_end_en < time.time():  # 此時的時候已經超時,需要再次從新進行點擊
            print('en模擬點擊')
            # 從新定義開始結束時間
            print(self.date_end_en, time.time())
            self.date_end_en = time.time() + self.hours_en  # 再次更改end time為n小時后
            print(self.date_end_en, time.time())
            try:
                # print('id定位en')
                en_app = self.wait.until(
                    EC.presence_of_element_located((By.XPATH, f"//android.widget.TextView[@text='textname…']")))
                # en_master = self.wait.until(EC.presence_of_element_located((By.ID, 'com.tencent.mm:id/hu')))
                # en_master = self.wait.until(
                # EC.presence_of_element_located((By.XPATH, "//android.widget.TextView[@text='textname']")))
                en_app.click()
                logging.info(f'located by app_name en')
            except Exception as error:
                # print(e, 'id定位失敗')
                logging.info(f'failed located by id:{error}')
            time.sleep(20)
            # 關閉小程式按鈕點擊
            print('close the en app')
            close_button = self.wait.until(EC.presence_of_element_located((By.XPATH, f"//android.widget.FrameLayout[2]/android.widget.ImageButton")))
            close_button.click()
            print('點擊了關閉小程式')

    def touch_xd(self):
        """
        需要考慮是否已經登錄狀態還是需要再次登錄
        :return:
        """
        # 點擊后進入到小程式
        logging.info('click app xd')
        xd_app = self.wait.until(EC.presence_of_element_located((By.XPATH, "//android.widget.TextView[@text='textname']")))
        xd_app.click()
        time.sleep(20)
        # 頁面出現需要獲取到你的定位的時候需要點擊允許
        print('點擊確認獲取當前位置')
        self.driver.tap([(510, 679)], 500)

        # 點擊進入到個人中心
        time.sleep(10)
        logging.info('click personal xd')
        self.driver.tap([(540, 1154)], 500)
        # 點擊快速登錄進行登錄
        time.sleep(10)
        logging.info('click login xd')
        self.driver.tap([(270, 1030)], 500)
        # 點擊同意獲取頭像資訊
        time.sleep(10)
        logging.info('同意獲取頭像等相關資訊')
        self.driver.tap([(510, 775)], 500)
        time.sleep(20)
        # 關閉小程式按鈕點擊
        print('close the guaishou app')
        close_button = self.wait.until(
            EC.presence_of_element_located((By.XPATH, f"//android.widget.FrameLayout[2]/android.widget.ImageButton")))
        close_button.click()
        print('結束')
        time.sleep(30)

    def touch_xiu(self):
        """
        xiu模擬點擊,需要考慮是否需要登錄狀態下
        :return:
        """
        # 點擊后進入到小程式
        logging.info('click app xiu')
        xiu_app = self.wait.until(EC.presence_of_element_located((By.XPATH, "//android.widget.TextView[@text='xiu']")))
        xiu_app.click()
        # 若頁面顯示需要確認獲取當前位置的話需要點擊確認
        logging.info('click confirm xiu')
        time.sleep(15)
        confirm_loc = self.wait.until(
            EC.presence_of_element_located((By.XPATH, "//android.widget.Button[@text='確定']")))
        confirm_loc.click()
        # 點擊個人中心
        logging.info('click personal xiu')
        time.sleep(5)
        try:
            personal = self.wait.until(
                EC.presence_of_element_located((By.XPATH, "//android.view.View[@content-desc='個人中心']")))
            personal.click()
        except Exception as e:
            print(e)
        # 點擊快速登錄進行登錄
        logging.info('click login xiu')
        time.sleep(5)
        try:
            login = self.wait.until(EC.presence_of_element_located((By.XPATH, "//android.view.View[@content-desc='立即登錄']")))
            login.click()
        except Exception as e:
            print('xiu已經登錄,不需要再次點擊確認登錄')
        time.sleep(30)

    def driver_closed(self):
        self.driver.quit()


if __name__ == '__main__':
    conn_r = RedisClient(db=10)
    count_1 = 0
    # start_time = time.time()
    # end_time = time.time() + 60 * 60 * 1
    we_chat = WeChat()
    try:
        while 1:
            if conn_r.r_size() < 3:  # 監控Redis情況,當Redis中無資料后開始運行一次
                res = we_chat.run()  # 操作微信做操作點擊en小程式生成token
                if not res:
                    count_1 += 1
                    if count_1 > 10:
                        break  # 當失敗十次之后跳出回圈
                # 此處增加限制,每次生成token之后一個小時后才會產生新的token,防止一個token多次使用導致被封號
                time.sleep(60*60)
            else:
                time.sleep(60*60)  # 當有資料的時候等待五分鐘
            we_chat.driver = webdriver.Remote(DRIVER_SERVER, we_chat.desired_caps)
            we_chat.wait = WebDriverWait(we_chat.driver, TIMEOUT)
    except Exception as e:
        msg = f'業務報警:' \
            f'\n en獲取token出現問題' \
            f'\n{e}'
        send_msg(msg)
        # print(e, type(e))
        logging.info(msg)
weixin.py
import os

# 平臺
PLATFORM = 'Android'

# 設備名稱 通過 adb devices -l 獲取
DEVICE_NAME = 'MI_9'

# APP路徑
APP = os.path.abspath('.') + '/weixin.apk'

# APP包名
APP_PACKAGE = 'com.tencent.mm'

# 入口類名
APP_ACTIVITY = '.ui.LauncherUI'

# Appium地址
DRIVER_SERVER = 'http://localhost:4723/wd/hub'
# 等待元素加載時間
TIMEOUT = 10

# 微信手機號密碼
USERNAME = 'wechatname'
PASSWORD = 'wechatpwd'

# 滑動點
FLICK_START_X = 300
FLICK_START_Y = 300
FLICK_DISTANCE = 700
config.py

以下是處理檔案,將token獲取到后放到Redis中,或者你可以依照你的想法調整

import re
import os
import logging

from conf.dbr import RedisClient

LOG_FORMAT = "%(asctime)s - %(levelname)s - line:%(lineno)s - msg:%(message)s"
logging.basicConfig(level=logging.DEBUG, format=LOG_FORMAT)


# 處理en token到Redis
class EnToken(object):
    def __init__(self):
        # self.token_path = 'F:\\en.txt'
        # self.token_path = 'F:\\xiu.txt'
        # self.token_path = 'F:\\xd.txt'
        self.conn = RedisClient(db=10)  # 決議日維度價格
        self.conn_en = RedisClient(db=9)  # 決議當前經緯度范圍內店鋪點位

    # 處理en token檔案,從檔案中讀取到token之后只取最后一個,取到之后洗掉本地檔案
    @staticmethod
    def handle_en_txt():
        token_dict = {}
        path_token_list = [
            ('en', '>(e.*?)-->'),
            ('xd', 'headers-->(.*?)-->'),
            ('xiu', r'>(\d+)-->'),
                      ]
        for i in path_token_list:
            token_path = f'F:\\{i[0]}.txt'
            token_re = i[-1]
            if os.path.exists(token_path):
                with open(token_path, mode='r', encoding='utf-8') as f:
                    token_str = f.read()
                    # print(token_str)
                    # token_list = re.findall('>(e.*?)-->', token_str)
                    # token_list = re.findall('>(Q.*?)-->', token_str)
                    # token_list = re.findall('>(\d+)-->', token_str)
                    token_list = re.findall(token_re, token_str)
                    print(token_list)
                    if token_list:
                        token = token_list[-1]
                        print(token)
                        token_dict[i[0]] = token
                os.remove(token_path)  # 洗掉掉
            # return token
        else:
            # print('file_en_dont_exit')
            logging.info('file_en_dont_exit')
        return token_dict

    # 將token放到Redis中
    def token_2_redis(self):
        """
        假如token存在的話 則根據token的最后幾位做key放入到Redis中
        :return:
        """
        token_dict = self.handle_en_txt()
        print(token_dict)
        if token_dict:
            for token_items in token_dict.items():
                token_key = token_items[0]
                token_val = token_items[-1]
                self.conn.set(token_key, token_val, over_time=None)
                # self.conn.set(token_key, token, over_time=60*65)  # 設定有效時長65分鐘之后失效
                # self.conn_en.set(token_key, token, over_time=60*65)  # 設定有效時長65分鐘之后失效
                logging.info(f'token success {token_key,token_val}')
            return True
        else:
            logging.info('token dons"t exist')
        self.conn.close()
        self.conn_en.close()


if __name__ == '__main__':
    en = EnToken()
    en.token_2_redis()
handle_file.py

  二、配置fiddler獲取請求頭的資訊寫到本地檔案

修改fiddlerscript添加以下內容,在做資料請求的以下增加下面內容

if (oSession.oRequest["Host"]=="這里是請求的host") {
                    var filename = "F:\en.txt";
                    var curDate = new Date();
                    var logContent = 'en' + "[" + curDate.toLocaleString() +  "]";
                    var sw : System.IO.StreamWriter;
                    if (System.IO.File.Exists(filename)){
                          sw = System.IO.File.AppendText(filename);
                          sw.Write(logContent + 'oSession.oRequest.headers-->'  + oSession.oRequest.headers['x-wx-token'] + '-->' + oSession.oRequest.headers  +'\n');
                          // sw.Write("Request header:" + "\n" +  oSession.oRequest.headers);
                          // sw.Write(wap_s + '\n\n')
                    }
                    else{
                          sw = System.IO.File.CreateText(filename);
                          sw.Write(logContent + 'oSession.oRequest.headers-->'  + oSession.oRequest.headers['x-wx-token'] + '-->' + '\n');
                          // sw.Write("Request header:" + "\n" +  oSession.oRequest.headers);
                          // sw.Write(wap_s + '\n\n')
                    }
                    sw.Close();
                    sw.Dispose();
             }
fiddler

  三、主爬蟲業務代碼

  此處按照自己的需求邏輯調整自己的業務代碼,

如果對你有所幫助就請作者喝杯咖啡吧??

 

 

  

  

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/303161.html

標籤:Python

上一篇:??【Android精進之路-03】創建第一個Android應用程式竟然如此簡單??

下一篇:一起用python做個炫酷音樂播放器,想聽啥隨便搜

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more