php爬蟲之有道詞典獲取詞條資訊

2021-09-29 10:37:49 字數 1263 閱讀 3179

檔案目錄

;//要爬取的**

echo

$url

;$ch

=curl_init()

;curl_setopt

($ch

,curlopt_url

,$url);

curl_setopt (

$ch,

curlopt_header

,false);

curl_setopt

($ch

,curlopt_ssl_verifypeer

,false);

curl_setopt

($ch

,curlopt_ssl_verifyhost

,false);

//設定使用者**(字尾為.top的**不加這個獲取不到內容。)

curl_setopt

($ch

,curlopt_useragent,)

;//關閉直接輸出

curl_setopt

($ch

,curlopt_returntransfer,1

);//加入重定向處理

curl_setopt

($ch

,curlopt_followlocation,1

);$response

=curl_exec

($ch);

echo

curl_errno

($ch);

echo

($response);

curl_close

($ch);

?>

執行結果

ubuntu下有道詞典不能取詞

安裝完有道後,發現不能劃詞 取詞。在shell終端驅動youdao dict後進行螢幕取詞翻譯,顯示如下錯誤 qopenglshaderprogram uniformlocation qt matrix shader program is not linked經過調查發現是有道詞典找不到顯示卡驅動問...

爬蟲 爬取有道詞典

首次匯入模組 import requests import json import hashlib import random import time def md5 value 建立md5物件 md5 obj hashlib.md5 加密字串 md5 obj.update bytes value,...

Python 網路爬蟲抓取有道詞典

content input 請輸入需要翻譯的內容 輸入 e 退出程式 if content e break url 有道詞典的請求 head 設定乙個頭部使得瀏覽器認為不是用python進行訪問 head user agent mozilla 5.0 windows nt 10.0 win64 x6...