編譯安裝redis

来源:https://www.cnblogs.com/www233ii/archive/2020/02/13/12303139.html

編譯安裝redisd [toc] 安裝方法: yum安裝 1. 查看yum倉庫redis版本 2. yum安裝 3. 啟動服務並設為開機啟動 4. 查看redis埠 5. 測試登錄redis 6. 測試使用 編譯安裝 下載當前最新release版本redis源碼包 :http://download ...


編譯安裝redisd

安裝方法:

yum安裝

  1. 查看yum倉庫redis版本
[[email protected] ~]# yum list redis
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Packages
redis.x86_64                             3.2.12-2.el7                              myepel
  1. yum安裝
[[email protected] ~]# yum install redis -y
  1. 啟動服務並設為開機啟動
[[email protected] ~]# systemctl enable --now redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.              
  1. 查看redis埠
[[email protected] ~]# ss -ntl
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port              
LISTEN      0      128      127.0.0.1:631                          *:*                  
LISTEN      0      100      127.0.0.1:25                           *:*                  
LISTEN      0      128      127.0.0.1:6010                         *:*                  
LISTEN      0      128              *:54909                        *:*                  
LISTEN      0      128      127.0.0.1:6379                         *:*                  # 這個是redis埠
LISTEN      0      128              *:111                          *:*                  
LISTEN      0      5      192.168.122.1:53                           *:*   
  1. 測試登錄redis
[[email protected] ~]# redis-cli
127.0.0.1:6379> info
# Server
redis_version:3.2.12
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:7897e7d0e13773f
redis_mode:standalone
os:Linux 3.10.0-1062.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
gcc_version:4.8.5
process_id:2914
run_id:c75137717c54caa78bb05757d05c91471ef5817f
tcp_port:6379
uptime_in_seconds:175
uptime_in_days:0
hz:10
lru_clock:4329484
executable:/usr/bin/redis-server
config_file:/etc/redis.conf

# Clients
connected_clients:1
client_longest_output_list:0
client_biggest_input_buf:0
blocked_clients:0
  1. 測試使用
127.0.0.1:6379> set key1 value1
OK
127.0.0.1:6379> get key1
"value1"

編譯安裝

下載當前最新release版本redis源碼包:http://download.redis.io/releases/
在這裡插入圖片描述

  1. 編譯安裝命令
    官方安裝命令:https://redis.io/download
# 源碼包存放目錄
[[email protected] ~]# cd /usr/local/src/
# 下載源碼包
[[email protected] src]# wget http://download.redis.io/releases/redis-5.0.7.tar.gz
--2020-02-11 10:37:54--  http://download.redis.io/releases/redis-5.0.7.tar.gz
Resolving download.redis.io (download.redis.io)... 109.74.203.151
Connecting to download.redis.io (download.redis.io)|109.74.203.151|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1984203 (1.9M) [application/x-gzip]
Saving to: ‘redis-5.0.7.tar.gz’

100%[===============================================>] 1,984,203   6.75KB/s   in 3m 35s 

2020-02-11 10:41:39 (9.02 KB/s) - ‘redis-5.0.7.tar.gz’ saved [1984203/1984203]
# 查看下載好的源碼包
[[email protected] src]# ll
total 1940
-rw-r--r-- 1 root root 1984203 Nov 20 01:06 redis-5.0.7.tar.gz
  1. 解壓源碼包
[[email protected] src]# tar xf redis-5.0.7.tar.gz 
[[email protected] src]# ll
total 1940
drwxrwxr-x 6 root root     334 Nov 20 01:05 redis-5.0.7
-rw-r--r-- 1 root root 1984203 Nov 20 01:06 redis-5.0.7.tar.gz
  1. 創建配置文件、日誌、數據等目錄
[[email protected] ~]# mkdir /apps/redis/{etc,logs,data,run} -p
# 查看目錄結構
[[email protected] ~]# tree /apps/
/apps/
└── redis
    ├── data
    ├── etc
    ├── logs
    └── run
  1. 進入redis目錄編譯安裝
[[email protected] ~]# cd /usr/local/src/redis-5.0.7/
[[email protected] redis-5.0.7]# make PREFIX=/apps/redis install
cd src && make install
make[1]: Entering directory `/usr/local/src/redis-5.0.7/src'
    CC Makefile.dep
make[1]: Leaving directory `/usr/local/src/redis-5.0.7/src'
make[1]: Entering directory `/usr/local/src/redis-5.0.7/src'
    CC adlist.o
/bin/sh: cc: command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/usr/local/src/redis-5.0.7/src'
make: *** [install] Error 2

# 出現以上報錯是沒有gcc編譯器導致的
# 下載gcc編譯器
[[email protected] redis-5.0.7]# yum install gcc
# 記得這裡要把之前的redis目錄刪除重新解壓
[[email protected] src]# rm -rf redis-5.0.7
[[email protected] src]# tar xf redis-5.0.7.tar.gz 

# 重新進入目錄進行編譯
[[email protected] src]# cd redis-5.0.7/
[[email protected] redis-5.0.7]# make PREFIX=/apps/redis install  # 指定安裝目錄
cd src && make install
make[1]: Entering directory `/usr/local/src/redis-5.0.7/src'
    CC Makefile.dep
make[1]: Leaving directory `/usr/local/src/redis-5.0.7/src'
make[1]: Entering directory `/usr/local/src/redis-5.0.7/src'
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark
(cd ../deps && make distclean)
make[2]: Entering directory `/usr/local/src/redis-5.0.7/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/usr/local/src/redis-5.0.7/deps'
(rm -f .make-*)
....(省略)
Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/usr/local/src/redis-5.0.7/src'
# 最後報這個就是編譯完成
  1. 拷貝配置文件
[[email protected] redis-5.0.7]# ll 
total 276
-rw-rw-r--  1 root root 115100 Nov 20 01:05 00-RELEASENOTES
-rw-rw-r--  1 root root     53 Nov 20 01:05 BUGS
-rw-rw-r--  1 root root   2381 Nov 20 01:05 CONTRIBUTING
-rw-rw-r--  1 root root   1487 Nov 20 01:05 COPYING
drwxrwxr-x  6 root root    192 Feb 11 11:32 deps
-rw-rw-r--  1 root root     11 Nov 20 01:05 INSTALL
-rw-rw-r--  1 root root    151 Nov 20 01:05 Makefile
-rw-rw-r--  1 root root   6888 Nov 20 01:05 MANIFESTO
-rw-rw-r--  1 root root  20555 Nov 20 01:05 README.md
-rw-rw-r--  1 root root  61797 Nov 20 01:05 redis.conf
-rwxrwxr-x  1 root root    275 Nov 20 01:05 runtest
-rwxrwxr-x  1 root root    280 Nov 20 01:05 runtest-cluster
-rwxrwxr-x  1 root root    373 Nov 20 01:05 runtest-moduleapi
-rwxrwxr-x  1 root root    281 Nov 20 01:05 runtest-sentinel
-rw-rw-r--  1 root root   9710 Nov 20 01:05 sentinel.conf
drwxrwxr-x  3 root root   8192 Feb 11 11:33 src
drwxrwxr-x 11 root root    182 Nov 20 01:05 tests
drwxrwxr-x  8 root root   4096 Nov 20 01:05 utils
[[email protected] redis-5.0.7]# cp redis.conf /apps/redis/etc/
  1. 啟動redis(這個啟動方式)
[[email protected] redis-5.0.7]# /apps/redis/bin/redis-server /apps/redis/etc/redis.conf 
8315:C 11 Feb 2020 11:40:12.016 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
8315:C 11 Feb 2020 11:40:12.016 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=8315, just started
8315:C 11 Feb 2020 11:40:12.016 # Configuration loaded
8315:M 11 Feb 2020 11:40:12.017 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 8315
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

8315:M 11 Feb 2020 11:40:12.017 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
8315:M 11 Feb 2020 11:40:12.017 # Server initialized
8315:M 11 Feb 2020 11:40:12.017 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
8315:M 11 Feb 2020 11:40:12.017 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
8315:M 11 Feb 2020 11:40:12.018 * Ready to accept connections
  1. 解決當前的警告提示
  • tcp-backlog

The backlog argument defines the maximum length to which the queue of pending connections for sockfdmay grow. If a connection request arrives when the queue is full, the client may receive an error with an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds.

backlog參數控制的是三次握手的時候server端收到client ack確認號之後的隊列值。

[[email protected] ~]# echo 511 > /proc/sys/net/core/somaxconn
  • vm.overcommit_memory
    0、表示內核將檢查是否有足夠的可用記憶體供應用進程使用;如果有足夠的可用記憶體,記憶體申請允許;否則,記憶體申請失敗,並把錯誤返回給應用進程。 1、表示內核允許分配所有的物理記憶體,而不管當前的記憶體狀態如何。 2、表示內核允許分配超過所有物理記憶體和交換空間總和的記憶體
[[email protected] ~]# echo "vm.overcommit_memory = 1" >/etc/sysctl.conf
  • transparent hugepage
    大頁記憶體動態分配,需要關閉讓redis 負責記憶體管理。
[[email protected] ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled
  1. 重啟一下服務
# 再次啟動服務,警告信息沒有了。
[[email protected] ~]# /apps/redis/bin/redis-server /apps/redis/etc/redis.conf 
1847:C 13 Feb 2020 12:03:59.281 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1847:C 13 Feb 2020 12:03:59.281 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=1847, just started
1847:C 13 Feb 2020 12:03:59.281 # Configuration loaded
1847:M 13 Feb 2020 12:03:59.282 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 1847
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

1847:M 13 Feb 2020 12:03:59.282 # Server initialized
1847:M 13 Feb 2020 12:03:59.282 * DB loaded from disk: 0.000 seconds
1847:M 13 Feb 2020 12:03:59.282 * Ready to accept connections
  1. 編輯redis服務啟動腳本
[[email protected] ~]# cat /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis persistent key-value database
After=network.target
After=network-online.target
Wants=network-online.target

[Service]
#ExecStart=/usr/bin/redis-server /etc/redis.conf --supervised systemd
ExecStart=/apps/redis/bin/redis-server /apps/redis/etc/redis.conf --supervised systemd
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
Type=notify
User=redis
Group=redis
RuntimeDirectory=redis
RuntimeDirectoryMode=0755

[Install]
WantedBy=multi-user.target
  1. 添加redis用戶
# 添加用戶和組
[[email protected] ~]# groupadd -g 1001 redis && useradd -u 1001 -g 1001 redis -s /sbin/nologin
# 數據目錄設置所有者所屬組
[[email protected] ~]# chown redis.redis -R /apps/redis/
  1. system啟動測試
# 開啟redis並設為開機啟動
[[email protected] ~]# systemctl enable --now redis
Created symlink from /etc/systemd/system/multi-user.target.wants/redis.service to /usr/lib/systemd/system/redis.service.

# 查看埠
[[email protected] ~]# ss -tnl
State      Recv-Q Send-Q                                         Local Address:Port                                                        Peer Address:Port              
LISTEN     0      128                                                127.0.0.1:631                                                                    *:*                  
LISTEN     0      100                                                127.0.0.1:25                                                                     *:*                  
LISTEN     0      128                                                127.0.0.1:6010                                                                   *:*                  
LISTEN     0      128                                                127.0.0.1:6011                                                                   *:*                  
LISTEN     0      128                                                        *:43108                                                                  *:*                  
LISTEN     0      511                                                127.0.0.1:6379                                                                   *:*  # 這個為redis埠                
LISTEN     0      128                                                        *:111                                                                    *:*                  
LISTEN     0      5                                              192.168.122.1:53                                                                     *:*                  
LISTEN     0      128                                                        *:22                                                                     *:*                  
LISTEN     0      128                                                    [::1]:631                                                                 [::]:*                  
LISTEN     0      100                                                    [::1]:25                                                                  [::]:*                  
LISTEN     0      128                                                    [::1]:6010                                                                [::]:*                  
LISTEN     0      128                                                    [::1]:6011                                                                [::]:*                  
LISTEN     0      128                                                     [::]:59279                                                               [::]:*                  
LISTEN     0      128                                                     [::]:111                                                                 [::]:*                  
LISTEN     0      128                                                     [::]:22                                                                  [::]:*            
  1. 客戶端連接redis測試
# 這裡還沒有把這個命令加到PATH變數里
[[email protected] ~]# /apps/redis/bin/redis-cli 
127.0.0.1:6379> info
# Server
redis_version:5.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:b0887378c143d6e9
redis_mode:standalone
os:Linux 3.10.0-1062.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.5
process_id:2088
run_id:e0bbd2dc1561d1610565c6c8fb61aa817e30924c
tcp_port:6379
  1. 創建命令軟連接(也可以把這個路徑加到PATH變數裡面)
[[email protected] ~]# ln -sv /apps/redis/bin/redis-* /usr/bin/
‘/usr/bin/redis-benchmark’ -> ‘/apps/redis/bin/redis-benchmark’
‘/usr/bin/redis-check-aof’ -> ‘/apps/redis/bin/redis-check-aof’
‘/usr/bin/redis-check-rdb’ -> ‘/apps/redis/bin/redis-check-rdb’
‘/usr/bin/redis-cli’ -> ‘/apps/redis/bin/redis-cli’
‘/usr/bin/redis-sentinel’ -> ‘/apps/redis/bin/redis-sentinel’
‘/usr/bin/redis-server’ -> ‘/apps/redis/bin/redis-server’

# 命令連接測試
[[email protected] ~]# redis-cli 
127.0.0.1:6379> info
# Server
redis_version:5.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:b0887378c143d6e9
redis_mode:standalone
os:Linux 3.10.0-1062.el7.x86_64 x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:4.8.5
process_id:2088
run_id:e0bbd2dc1561d1610565c6c8fb61aa817e30924c
tcp_port:6379
uptime_in_seconds:755
uptime_in_days:0
[[email protected] ~]# ll /apps/redis/bin/
total 32772
-rwxr-xr-x 1 redis redis 4366824 Feb 11 11:33 redis-benchmark   # redis性能測試工具
-rwxr-xr-x 1 redis redis 8125216 Feb 11 11:33 redis-check-aof   # AOF文件檢查工具
-rwxr-xr-x 1 redis redis 8125216 Feb 11 11:33 redis-check-rdb   # RDB文件檢查工具 
-rwxr-xr-x 1 redis redis 4807896 Feb 11 11:33 redis-cli         # 客戶端工具
lrwxrwxrwx 1 redis redis      12 Feb 11 11:33 redis-sentinel -> redis-server # 哨兵軟連接到server
-rwxr-xr-x 1 redis redis 8125216 Feb 11 11:33 redis-server      # redis 服務啟動命令
**以上就是redis的安裝方法和一些小問題的解決方法了!**

您的分享是我們最大的動力!

更多相關文章
  • 網站地址: https://www.90pan.com/b1268487 迅雷鏈接: magnet:?xt=urn:btih:EE4B0FE780B6EC97D6FB9A9D22A8EE1627DA78A2 占用記憶體小,文字太少再湊點字數。迅雷就是比網盤好,哦耶!!!! 到底多少字才能發佈啊——__ ...
  • 未來的某個時間點執行一次某任務的命令: ,`batch` 命令執行的結果,會發送到任務發起者的郵箱 周期性運行某任務: 命令執行的結果,會發送到任務發起者的郵箱 本地郵件服務 發郵件的協議:smtp(simple mail transmission protocol) 收郵件的協議: pop3(po ...
  • 註意,這裡用char類型只是舉了一個例子,其他的int之類的也通用。 1: 常量: 例子: char str[] = "Hello world!"; char ch = 'a'; int i = 12345; 我們看等號右邊的,這些就叫常量。常量在程式運行過程中不會發生改變,並且隨著程式一起裝入記憶體 ...
  • 下載安裝Kibana 1. 下載地址:https://www.elastic.co/cn/downloads/kibana 2. 解壓下載的壓縮包 [[email protected] ~]# tar -zxvf kibana-7.6.0-linux-x86_64.tar.gz 3. 給es用戶分配許可權 ...
  • 前面文章分享了Linux下常用命令以及Shell編程相關知識,本節繼續學習Linux用戶管理及文件許可權控制。 ...
  • CRUD 在我們的項目中有日誌是一個必不可少的東西,但是日誌的檢索是一個很麻煩的事情,如每天一個日誌,要找到問題就得一個一個找,並不能做到檢索功能,這還算好的,如果是分散式的,每個機器都得找一遍,這種效率太低,當然可以把日誌收集到一個文件中,多個機器每天的日誌可以收集到一塊,如果把所有的日誌收集一塊 ...
  • sprd_battery.c 是充電驅動,這個是充電功能的核心內容,電量顯示策略、溫度檢測策略、充電保護機制等功能在這裡實現,功能實現與硬體細節剝離,調用通用介面實現邏輯控制; 1 sprdbat_probe函數: 1.1 解析設備樹: sprdbat_parse_dt函數如下: 2. 各個工作隊列 ...
  • 鳴謝:http://blog.csdn.net/leimengyuanlian/article/details/18748599 http://www.cnblogs.com/maowang1991/archive/2013/02/05/2893142.html https://www.cnblog ...
一周排行
  • 比如要拆分“呵呵呵90909086676喝喝999”,下麵當type=0返回的是中文字元串“呵呵呵,喝喝”,type=1返回的是數字字元串“90909086676,999”, private string GetStrings(string str,int type=0) { IList<strin ...
  • Swagger一個優秀的Api介面文檔生成工具。Swagger可以可以動態生成Api介面文檔,有效的降低前後端人員關於Api介面的溝通成本,促進項目高效開發。 1、使用NuGet安裝最新的包:Swashbuckle.AspNetCore。 2、編輯項目文件(NetCoreTemplate.Web.c ...
  • 2020 年 7 月 30 日, 由.NET基金會和微軟 將舉辦一個線上和為期一天的活動,包括 微軟 .NET 團隊的演講者以及社區的演講者。本次線上大會 專註.NET框架構建微服務,演講者分享構建和部署雲原生應用程式的最佳實踐、模式、提示和技巧。有關更多信息和隨時瞭解情況:https://focu... ...
  • #abp框架Excel導出——基於vue #1.技術棧 ##1.1 前端採用vue,官方提供 UI套件用的是iview ##1.2 後臺是abp——aspnetboilerplate 即abp v1,https://github.com/aspnetboilerplate/aspnetboilerp ...
  • 前言 本文的文字及圖片來源於網路,僅供學習、交流使用,不具有任何商業用途,版權歸原作者所有,如有問題請及時聯繫我們以作處理。 作者:碧茂大數據 PS:如有需要Python學習資料的小伙伴可以加下方的群去找免費管理員領取 input()輸入 Python提供了 input() 內置函數從標準輸入讀入一 ...
  • 從12年到20年,python以肉眼可見的趨勢超過了java,成為了當今It界人人皆知的編程語言。 python為什麼這麼火? 網路編程語言搜索指數 適合初學者 Python具有語法簡單、語句清晰的特點,這就讓初學者在學習階段可以把精力集中在編程對象和思維方法上。 大佬都在用 Google,YouT ...
  • 在社會上存在一種普遍的對培訓機構的學生一種歧視的現象,具體表現在,比如:當你去公司面試的時候,一旦你說了你是培訓機構出來的,那麼基本上你就涼了,那麼你瞞著不說,然後又通過了面試成功入職,但是以後一旦在公司被髮現有培訓經歷,可能會面臨被降薪,甚至被辭退,培訓機構出來的學生,在用人單位眼裡就是能力低下的 ...
  • from typing import List# 這道題看了大佬寫的代碼,經過自己的理解寫出來了。# 從最外圍的四周找有沒有為O的,如果有的話就進入深搜函數,然後深搜遍歷# 判斷上下左右的位置是否為Oclass Solution: def solve(self, board: List[List[s ...
  • import requests; import re; import os; # 1.請求網頁 header = { "user-agent":'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, li ...
  • import requests; import re; import os; import parsel; 1.請求網頁 header = { "user-agent":'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537. ...