某乎问答:有哪些仙气四溢的星空壁纸嘛?
url: https://www.zhihu.com/question/439483198/answer/1680920607
安装package
因为下载了多个版本的python
因此需要在cmd内pip install 指定python版本
cd python.exe所在目录
python -m pip install package
python
from bs4 import BeautifulSoup
import requests
import os
from fake_useragent import UserAgent
def getImg(question_url, file_dir='.\pic', show=False):
if not os.path.exists(file_dir):
os.mkdir(file_dir)
url = question_url
#随机请求头
headers = {
'user-agent':UserAgent().random