我能够成功打开 URL 并将生成的页面保存为 .html 文件。但是,我无法确定如何下载和保存 .mhtml(网页,单个文件)。
我的代码是:
import urllib.parse, time
from urllib.parse import urlparse
import urllib.request
url = ('https://www.example.com')
encoded_url = urllib.parse.quote(url, safe='')
print(encoded_url)
base_url = ("https://translate.google.co.uk/translate?sl=auto&tl=en&u=")
translation_url = base_url+encoded_url
print(translation_url)
req = urllib.request.Request(translation_url, headers={'User-Agent': 'Mozilla/6.0'})
print(req)
response = urllib.request.urlopen(req)
time.sleep(15)
print(response)
webContent = response.read()
print(webContent)
f = open('GoogleTranslated.html', 'wb')
f.write(webContent)
print(f)
f.close
Run Code Online (Sandbox Code Playgroud)
我尝试使用 wget 使用此问题中捕获的详细信息: How to download apages (mhtml format) using wget in python但详细信息不完整(或者我根本无法理解)。
在此阶段任何建议都会有所帮助。
我已经在 Windows 11 上使用 Python (3.7.0) 安装了 Mediapipe (0.9.0.1)。我已经能够成功让 Mediapipe 生成地标(用于面部和身体);用于图像、视频和网络摄像头流。
我现在想让 Mediapipe仅绘制身体特定的标志(即排除面部标志)。
我知道我可以使用 OpenCV (或 Czone)来实现这个目标,但是,我希望使用 Mediapipe (即使用draw_landmarksMediaPipe 库中的函数)来实现我的目标。
我正在尝试的具体代码(但有错误)如下:
#Initialize a list to store the detected landmarks.
landmarks = []
# Iterate over the Mediapipe detected landmarks.
for landmark in results.pose_landmarks.landmark:
# Append the Mediapipe landmark into the list.
landmarks.append((int(landmark.x * width), int(landmark.y * height),
(landmark.z * width)))
#create index list for specific landmarks
body_landmark_indices = [11,12,13,14,15,16,23,24,25,26,27,28,29,30,31,32]
landmark_list_body = []
#Create a list which …Run Code Online (Sandbox Code Playgroud)