【目錄】2019-04-02
第一部分:前言
一、所需工具(4個)
jupyter notebook(單進程用)、mongodb(存儲數(shù)據(jù)用)魄眉、studio-3t(查看數(shù)據(jù)用)、sublime(多進程用)
二、主要知識點(4個)
urlib庫队腐、requests庫、BeautifulSoup庫奏篙、正則表達式(很少)
三柴淘、操作流程(3個階段)
- 1、單個模塊運行:單個方法模塊調(diào)試通暢秘通,保證子程序沒有問題
- 2为严、單進程運行:參數(shù)寫死,請求一個圖集的結(jié)果
- 3肺稀、多進程運行:參數(shù)可變第股,請求多個圖集的結(jié)果
第二部分:正文
一、分析目標網(wǎng)站(4個關(guān)鍵問題)
1话原、確認數(shù)據(jù)是怎么加載的--找到ajax文件
2夕吻、找到各個圖集的區(qū)別--發(fā)現(xiàn)offset變化規(guī)律
下拉加載,依次點擊XHR文件查看繁仁,看到offset變化規(guī)律:0,20,40.....
3涉馅、定位詳情頁鏈接--在哪里?
各種嘗試后黄虱,發(fā)現(xiàn)詳情頁鏈接在article_url這個參數(shù)中
4控漠、定位圖片鏈接--在哪里?
preview的源代碼中可以發(fā)現(xiàn),BASE_DATA.galleryInfo里面gallery這個參數(shù)中就含有url鏈接盐捷。測試一下偶翅,copy其中的一個url:消除“\\”后訪問,發(fā)現(xiàn)就是圖集中圖片碉渡。
gallery中copy一個url:http://pb3.pstatp.com/origin/dfic-imagehandler/7e8da4a8-dad7-4951-bf81-78988fae40bb
二聚谁、設(shè)定思路步驟(9個步驟)
1、載入必要的包
# 1.導(dǎo)入必要的庫:
import requests #請求網(wǎng)頁用
from requests.exceptions import RequestException #做requests的異常處理
from urllib.parse import urlencode #url編碼用
from bs4 import BeautifulSoup #網(wǎng)頁解析用
import urllib #請求網(wǎng)頁用
import json #格式轉(zhuǎn)換用
import re #正則表達式用
import pymongo #連接數(shù)據(jù)庫用
import os #路徑相關(guān)的函數(shù)
from hashlib import md5 #圖片命名用
from multiprocessing import Pool #建立多進程用
2滞诺、請求索引頁
# 1.導(dǎo)入必要的庫:
import requests #請求網(wǎng)頁用
from requests.exceptions import RequestException #做requests的異常處理
from urllib.parse import urlencode #url編碼用
from bs4 import BeautifulSoup #網(wǎng)頁解析用
import urllib #請求網(wǎng)頁用
import json #格式轉(zhuǎn)換用
import re #正則表達式用
import pymongo #連接數(shù)據(jù)庫用
import os #路徑相關(guān)的函數(shù)
from hashlib import md5 #圖片命名用
from multiprocessing import Pool #建立多進程用
keyword='街拍圖片'
offset=0
#放在全局中形导,不要放在方法中,不然每次請求要重復(fù)寫headers參數(shù)习霹。
headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64)","Referer":"https://www.toutiao.com/"}
# 2.獲取索引頁并分析:
def get_page_index(offset, keyword):
data = {
'offset': offset,
'format': 'json',
'keyword': keyword,
'autoload': 'true',
'count': 20,
'cur_tab': 1, # cur_tab為3指的是圖集板塊朵耕,數(shù)過來第三個,若為1則指代綜合板塊
'from': 'search_tab'
}
url = 'https://www.toutiao.com/api/search/content/?' + urlencode(data)
try:
response = requests.get(url,headers=headers)
if response.status_code == 200:
return response.text
else:
return None
except RequestException:
print('請求索引頁錯誤')
return None
#8、定義一個主函數(shù)淋叶,調(diào)用之前的方法
def main(offset):
html=get_page_index(offset,keyword)
print(html)
# 9阎曹、只運行本文件中的主函數(shù)
if __name__=='__main__':
main(offset)
預(yù)期結(jié)果:返回結(jié)果跟索引頁的preview中一致
3、解析索引頁煞檩,得到詳情頁url
# 1.導(dǎo)入必要的庫:
import requests #請求網(wǎng)頁用
from requests.exceptions import RequestException #做requests的異常處理
from urllib.parse import urlencode #url編碼用
from bs4 import BeautifulSoup #網(wǎng)頁解析用
import urllib #請求網(wǎng)頁用
import json #格式轉(zhuǎn)換用
import re #正則表達式用
import pymongo #連接數(shù)據(jù)庫用
import os #路徑相關(guān)的函數(shù)
from hashlib import md5 #圖片命名用
from multiprocessing import Pool #建立多進程用
keyword='街拍圖片'
offset=20
#放在全局中处嫌,不要放在方法中,不然每次請求要重復(fù)寫headers參數(shù)斟湃。
headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64)","Referer":"https://www.toutiao.com/"}
# 2.獲取索引頁并分析:
def get_page_index(offset, keyword):
data = {
'offset': offset,
'format': 'json',
'keyword': keyword,
'autoload': 'true',
'count': 20,
'cur_tab': 1, # cur_tab為3指的是圖集板塊熏迹,數(shù)過來第三個,若為1則指代綜合板塊
'from': 'search_tab'
}
url = 'https://www.toutiao.com/api/search/content/?' + urlencode(data) #url寫錯,卡了3天啊
try:
response = requests.get(url,headers=headers)
if response.status_code == 200:
return response.text
else:
return None
except RequestException:
print('請求索引頁錯誤')
return None
# 3凝赛、解析索引頁內(nèi)容
# 分析ajax請求的返回結(jié)果注暗,拿到詳情頁的url
def parse_page_index(html):
data = json.loads(html) # 加載返回的json數(shù)據(jù)
if data and 'data' in data.keys(): #確保返回的信息中含有data這個信息
for item in data.get('data'):
yield item.get('article_url') #構(gòu)造一個生成器
#8、定義一個主函數(shù)墓猎,調(diào)用之前的方法
def main(offset):
html=get_page_index(offset,keyword)
for url in parse_page_index(html): #返回的是一個迭代器友存,每次輸出一個網(wǎng)址
print(url)
# 9、只運行本文件中的主函數(shù)
if __name__=='__main__':
main(offset)
預(yù)期結(jié)果:詳情頁的url
4陶衅、請求詳情頁
5、解析詳情頁直晨,得到目標圖片的url
# 1.導(dǎo)入必要的庫:
import requests #請求網(wǎng)頁用
from requests.exceptions import RequestException #做requests的異常處理
from urllib.parse import urlencode #url編碼用
from bs4 import BeautifulSoup #網(wǎng)頁解析用
import urllib #請求網(wǎng)頁用
import json #格式轉(zhuǎn)換用
import re #正則表達式用
import pymongo #連接數(shù)據(jù)庫用
import os #路徑相關(guān)的函數(shù)
from hashlib import md5 #圖片命名用
from multiprocessing import Pool #建立多進程用
keyword='街拍圖片'
offset=20
#放在全局中搀军,不要放在方法中,不然每次請求要重復(fù)寫headers參數(shù)勇皇。
headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64)","Referer":"https://www.toutiao.com/"}
# 2.獲取索引頁并分析:
def get_page_index(offset, keyword):
data = {
'offset': offset,
'format': 'json',
'keyword': keyword,
'autoload': 'true',
'count': 20,
'cur_tab': 1, # cur_tab為3指的是圖集板塊罩句,數(shù)過來第三個,若為1則指代綜合板塊
'from': 'search_tab'
}
url = 'https://www.toutiao.com/api/search/content/?' + urlencode(data) #url寫錯,卡了3天啊
try:
response = requests.get(url,headers=headers)
if response.status_code == 200:
return response.text
else:
return None
except RequestException:
print('請求索引頁錯誤')
return None
# 3敛摘、解析索引頁內(nèi)容
# 分析ajax請求的返回結(jié)果门烂,拿到詳情頁的url
def parse_page_index(html):
data = json.loads(html) # 加載返回的json數(shù)據(jù)
if data and 'data' in data.keys(): #確保返回的信息中含有data這個信息
for item in data.get('data'):
yield item.get('article_url') #構(gòu)造一個生成器
# 4、請求詳情頁的內(nèi)容
def get_page_detail(url):
try:
response = requests.get(url,headers=headers)
if response.status_code == 200:
return response.text
else:
return None
except RequestException:
print('詳情頁頁錯誤', url)
return None
# 5、解析詳情頁的內(nèi)容
def parse_page_detail(html,url):
try:
soup = BeautifulSoup(html, 'lxml') #解析詳情頁的內(nèi)容
title = soup.select('title')[0].get_text() #獲取文章title
images_pattern = re.compile('gallery: JSON.parse\("(.*?)"\)',re.S) #確定匹配模式
result = re.search(images_pattern,html) #匹配內(nèi)容
str=re.sub(r'(\\)','',result.group(1)) #去掉url鏈接中防作弊的多余的雙斜線“\\”
if str: #如果匹配到內(nèi)容屯远,執(zhí)行接下來的操作
data = json.loads(str)
if data and 'sub_images' in data.keys(): #確保返回的信息中含有sub_images這個信息
sub_images=data.get('sub_images')
images=[item.get('url') for item in sub_images] #提取sub_images中圖片的url鏈接
return{
'title':title, #詳情頁標題
'url':url, #詳情頁鏈接
'images':images #圖片鏈接
}
except:
return None #跳過異常繼續(xù)執(zhí)行
#8蔓姚、定義一個主函數(shù),調(diào)用之前的方法
def main(offset):
html=get_page_index(offset,keyword)
for url in parse_page_index(html): #返回的是一個迭代器慨丐,每次輸出一個網(wǎng)址
html = get_page_detail(url)
if html:
result=parse_page_detail(html,url) #傳入詳情頁鏈接坡脐、詳情頁內(nèi)容,進行解析
print(result)
# 9房揭、只運行本文件中的主函數(shù)
if __name__=='__main__':
main(offset)
預(yù)期結(jié)果:詳情頁標題备闲、詳情頁鏈接、圖片鏈接
6捅暴、下載圖片 to 本地文件夾
7恬砂、返回數(shù)據(jù) to mongodb
# 1.導(dǎo)入必要的庫:
import requests #請求網(wǎng)頁用
from requests.exceptions import RequestException #做requests的異常處理
from urllib.parse import urlencode #url編碼用
from bs4 import BeautifulSoup #網(wǎng)頁解析用
import urllib #請求網(wǎng)頁用
import json #格式轉(zhuǎn)換用
import re #正則表達式用
import pymongo #連接數(shù)據(jù)庫用
from hashlib import md5 #圖片命名用
import os
from multiprocessing import Pool #建立多進程用
keyword='街拍圖片'
offset=100
MONGO_URL='localhost'
MONGO_DB='toutiao'
MONGO_TABLE='toutiao'
client = pymongo.MongoClient(MONGO_URL) # 連接MongoDB
db = client[MONGO_DB] # 如果已經(jīng)存在連接,否則創(chuàng)建數(shù)據(jù)庫
#放在全局中蓬痒,不要放在方法中泻骤,不然每次請求要重復(fù)寫headers參數(shù)。
headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64)","Referer":"https://www.toutiao.com/"}
# 2.獲取索引頁并分析:
def get_page_index(offset, keyword):
data = {
'offset': offset,
'format': 'json',
'keyword': keyword,
'autoload': 'true',
'count': 20,
'cur_tab': 1, # cur_tab為3指的是圖集板塊乳幸,數(shù)過來第三個,若為1則指代綜合板塊
'from': 'search_tab'
}
url = 'https://www.toutiao.com/api/search/content/?' + urlencode(data) #url寫錯瞪讼,卡了3天啊
try:
response = requests.get(url,headers=headers)
if response.status_code == 200:
return response.text
else:
return None
except RequestException:
print('請求索引頁錯誤')
return None
# 3、解析索引頁內(nèi)容
# 分析ajax請求的返回結(jié)果粹断,拿到詳情頁的url
def parse_page_index(html):
data = json.loads(html) # 加載返回的json數(shù)據(jù)
if data and 'data' in data.keys(): #確保返回的信息中含有data這個信息
for item in data.get('data'):
yield item.get('article_url') #構(gòu)造一個生成器
# 4符欠、請求詳情頁的內(nèi)容
def get_page_detail(url):
try:
response = requests.get(url,headers=headers)
if response.status_code == 200:
return response.text
else:
return None
except RequestException:
print('詳情頁頁錯誤', url)
return None
# 5、解析詳情頁的內(nèi)容
def parse_page_detail(html,url):
try:
soup = BeautifulSoup(html, 'lxml') #解析詳情頁的內(nèi)容
title = soup.select('title')[0].get_text() #獲取文章title
images_pattern = re.compile('gallery: JSON.parse\("(.*?)"\)',re.S) #確定匹配模式
result = re.search(images_pattern,html) #匹配內(nèi)容
str=re.sub(r'(\\)','',result.group(1)) #去掉url鏈接中防作弊的多余的雙斜線“\\”
if str: #如果匹配到內(nèi)容瓶埋,執(zhí)行接下來的操作
data = json.loads(str)
if data and 'sub_images' in data.keys(): #確保返回的信息中含有sub_images這個信息
sub_images=data.get('sub_images')
images=[item.get('url') for item in sub_images] #提取sub_images中圖片的url鏈接
for image in images:
download_img(image) #調(diào)用一個方法希柿,下載圖片
return{
'title':title, #詳情頁標題
'url':url, #詳情頁鏈接
'images':images #圖片鏈接
}
except:
return None #跳過異常繼續(xù)執(zhí)行
# 6、存儲到mongodb
def save_to_mongo(result):
if result:
if db[MONGO_TABLE].insert(result): # 插入數(shù)據(jù)
print('存儲成功', result)
return True
return False
# 7养筒、下載圖片(進度+存圖)
def download_img(url):
print('正在下載', url)
try:
response = requests.get(url, headers=headers)
if response.status_code == 200:
save_img(response.content) #content返回二進制內(nèi)容曾撤,圖片一般返回content
else:
return None
except RequestException:
print('下載圖片錯誤', url)
return None
#存儲圖片方法
def save_img(content):
#生成目標文件路徑,圖片用md5命名晕粪,保證不重復(fù)
file_path = '{0}/{1}.{2}'.format(r'C:\Users\luna\jiepai3', md5(content).hexdigest(), 'jpg')
if not os.path.exists(file_path):
with open(file_path, 'wb')as f:
f.write(content)
f.close()
#8挤悉、定義一個主函數(shù),調(diào)用之前的方法
def main(offset):
html=get_page_index(offset,keyword)
for url in parse_page_index(html): #返回的是一個迭代器巫湘,每次輸出一個網(wǎng)址
html = get_page_detail(url)
if html:
result=parse_page_detail(html,url) #傳入詳情頁鏈接装悲、詳情頁內(nèi)容,進行解析尚氛,下載圖片
save_to_mongo(result) #把返回內(nèi)容存入數(shù)據(jù)庫
# 9诀诊、只運行本文件中的主函數(shù)
if __name__=='__main__':
main(offset)
預(yù)期結(jié)果:
(1)運行結(jié)果
(2)本地文件夾載入圖片
(3)mongodb中載入數(shù)據(jù)
8、調(diào)用主函數(shù)
9阅嘶、啟動多進程
# 1.導(dǎo)入必要的庫:
import requests #請求網(wǎng)頁用
from requests.exceptions import RequestException #做requests的異常處理
from urllib.parse import urlencode #url編碼用
from bs4 import BeautifulSoup #網(wǎng)頁解析用
import urllib #請求網(wǎng)頁用
import json #格式轉(zhuǎn)換用
import re #正則表達式用
import pymongo #連接數(shù)據(jù)庫用
import os #路徑相關(guān)的函數(shù)
from hashlib import md5 #圖片命名用
from multiprocessing import Pool #建立多進程用
GROUP_START=1
GROUP_END=20
keyword='街拍圖片'
MONGO_URL='localhost'
MONGO_DB='toutiao'
MONGO_TABLE='toutiao'
client = pymongo.MongoClient(MONGO_URL) # 連接MongoDB
db = client[MONGO_DB] # 如果已經(jīng)存在連接属瓣,否則創(chuàng)建數(shù)據(jù)庫
#放在全局中载迄,不要放在方法中,不然每次請求要重復(fù)寫headers參數(shù)抡蛙。
headers={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64)","Referer":"https://www.toutiao.com/"}
# 2.獲取索引頁并分析:
def get_page_index(offset, keyword):
data = {
'offset': offset,
'format': 'json',
'keyword': keyword,
'autoload': 'true',
'count': 20,
'cur_tab': 1, # cur_tab為3指的是圖集板塊护昧,數(shù)過來第三個,若為1則指代綜合板塊
'from': 'search_tab'
}
url = 'https://www.toutiao.com/api/search/content/?' + urlencode(data) #url寫錯,卡了3天啊
try:
response = requests.get(url,headers=headers)
if response.status_code == 200:
return response.text
else:
return None
except RequestException:
print('請求索引頁錯誤')
return None
# 3溜畅、解析索引頁內(nèi)容
# 分析ajax請求的返回結(jié)果捏卓,拿到詳情頁的url
def parse_page_index(html):
data = json.loads(html) # 加載返回的json數(shù)據(jù)
if data and 'data' in data.keys(): #確保返回的信息中含有data這個信息
for item in data.get('data'):
yield item.get('article_url') #構(gòu)造一個生成器
# 4、請求詳情頁的內(nèi)容
def get_page_detail(url):
try:
response = requests.get(url,headers=headers)
if response.status_code == 200:
return response.text
else:
return None
except RequestException:
print('詳情頁頁錯誤', url)
return None
# 5慈格、解析詳情頁的內(nèi)容
def parse_page_detail(html,url):
try:
soup = BeautifulSoup(html, 'lxml') #解析詳情頁的內(nèi)容
title = soup.select('title')[0].get_text() #獲取文章title
images_pattern = re.compile('gallery: JSON.parse\("(.*?)"\)',re.S) #確定匹配模式
result = re.search(images_pattern,html) #匹配內(nèi)容
str=re.sub(r'(\\)','',result.group(1)) #去掉url鏈接中防作弊的多余的雙斜線“\\”
if str: #如果匹配到內(nèi)容怠晴,執(zhí)行接下來的操作
data = json.loads(str)
if data and 'sub_images' in data.keys(): #確保返回的信息中含有sub_images這個信息
sub_images=data.get('sub_images')
images=[item.get('url') for item in sub_images] #提取sub_images中圖片的url鏈接
for image in images:
download_img(image) #調(diào)用一個方法,下載圖片
return{
'title':title, #詳情頁標題
'url':url, #詳情頁鏈接
'images':images #圖片鏈接
}
except:
return None #跳過異常繼續(xù)執(zhí)行
# 6浴捆、存儲到mongodb
def save_to_mongo(result):
if result:
if db[MONGO_TABLE].insert(result): # 插入數(shù)據(jù)
print('存儲成功', result)
return True
return False
# 7蒜田、下載圖片(進度+存圖)
def download_img(url):
print('正在下載', url)
try:
response = requests.get(url, headers=headers)
if response.status_code == 200:
save_img(response.content) #content返回二進制內(nèi)容,圖片一般返回content
else:
return None
except RequestException:
print('下載圖片錯誤', url)
return None
#存儲圖片方法
def save_img(content):
#生成目標文件路徑选泻,圖片用md5命名冲粤,保證不重復(fù)
file_path = '{0}/{1}.{2}'.format(r'C:\Users\luna\jiepai3', md5(content).hexdigest(), 'jpg')
if not os.path.exists(file_path):
with open(file_path, 'wb')as f:
f.write(content)
f.close()
#8、定義一個主函數(shù)页眯,調(diào)用之前的方法
def main(offset):
html=get_page_index(offset,keyword)
for url in parse_page_index(html): #返回的是一個迭代器梯捕,每次輸出一個網(wǎng)址
html = get_page_detail(url)
if html:
result=parse_page_detail(html,url) #傳入詳情頁鏈接、詳情頁內(nèi)容窝撵,進行解析傀顾,下載圖片
save_to_mongo(result) #把返回內(nèi)容存入數(shù)據(jù)庫
# 9、只運行本文件中的主函數(shù)
if __name__=='__main__':
groups = [i * 20 for i in list(range(GROUP_START,GROUP_END))] # python3 range()不能直接生成列表碌奉,需要list一下
pool = Pool() #創(chuàng)建進程池
pool.map(main,groups) # 第一個參數(shù)是函數(shù)短曾,第二個參數(shù)是一個迭代器,將迭代器中的數(shù)字作為參數(shù)依次傳入函數(shù)中
預(yù)期結(jié)果:
(1)圖片大量存入文件夾
(2)mongodb中數(shù)據(jù)條數(shù)變多
第三部分:后記
一赐劣、耗時:2天
二嫉拐、感受(6點)
1、0編程基礎(chǔ)學(xué)習(xí)魁兼,各個節(jié)點都會卡你一下婉徘,主要是不熟悉各種報錯。
2咐汞、中間有一些支線任務(wù):比如說安裝工具盖呼,會耽擱一些時間。
3碉考、明確知道自己有拖延癥的人,沒必要開頭就一股腦安裝一堆工具挺身,到了要用的時候再安裝吧侯谁,不然很難起頭開始做。mongodb、stduio-3t都是到了步驟5我才安裝的
4墙贱、實在找不到問題热芹,找會的人問一下。別人點撥一下惨撇,會更容易找到錯誤點伊脓。我應(yīng)該是qq群里問過一個問題,其它都是百度+自己調(diào)試解決魁衙。
5、新人小白的方法:
(1)化整為零,代碼一段一段跑通总滩,這樣容易推進一些介汹。
(2)明確自己的預(yù)期結(jié)果。代碼運行后纵隔,如果返回結(jié)果跟預(yù)期結(jié)果一致翻诉,那就通過;如果不一致捌刮,那就繼續(xù)找問題碰煌。
6、這一天太能坐了绅作,竟然坐了9個小時芦圾。搞完后,胸悶氣短了棚蓄,趕緊走走堕扶,坑爹啊,以后不能這樣了梭依!
三稍算、總結(jié)問題,踩的坑(10個)
1役拴、chrome中F12后糊探,preview不顯示源代碼,顯示的是網(wǎng)頁或者圖片河闰。
這個是谷歌瀏覽器的bug科平,換個瀏覽器就好了。
2姜性、找不到offset
篩選XHR文件瞪慧,在headers欄目,Query String Parameters模塊部念,就可以看到offset的變化弃酌。
3氨菇、xhr是什么文件類型?
xhr:XMLHttpRequest在后臺與服務(wù)器交換數(shù)據(jù)妓湘,這意味著可以在不加載整個網(wǎng)頁的情況下查蓉,對網(wǎng)頁某部分的內(nèi)容進行更新。它是Ajax的一種用法榜贴,而Ajax并不是一門語言豌研,只是一種不需要加載整個網(wǎng)頁,只是更新局部內(nèi)容的技術(shù)唬党。
4鹃共、json書寫格式什么樣?
對象:{"name":"Michael","age":24}
數(shù)組:比如:[{"name":"Michael","age":24},{"name":"Tom","age":25}]
值:{"name":"Michael", "birthday":{"month":8,"day":26}}初嘹,類似于對象嵌套對象.
5及汉、query string parameters 這是什么啊屯烦?
Query String Parameters指的就是通過在URL中攜帶的方式提交的參數(shù)坷随,也就是get請求中需要的參數(shù)
6、如何簡單的理解Python中的if name == 'main' 這個用法
當(dāng)前理解:只運行本文件中主函數(shù)
7驻龟、多進程作用
在爬蟲中主要目的是提高爬取的效率温眉,實現(xiàn)秒爬
8、多進程創(chuàng)建和使用
在Windows上要想使用進程模塊翁狐,就必須把有關(guān)進程的代碼寫在當(dāng)前.py文件的
if __name__=='__main__':
pool = Pool() #創(chuàng)建進程池
語句的下面类溢,才能正常使用Windows下的進程模塊。Unix/Linux下則不需要露懒。
9闯冷、多進程在notebook中卡死的問題。
解決辦法:換在編輯器中運行懈词,例如蛇耀,我就是在sublime text運行python
10、mongodb的安裝和啟動
(1)下載一個mongodb安裝包進行安裝
(2)配置系統(tǒng)變量
(3)用cmd啟動:
- 第一步坎弯,用cd轉(zhuǎn)入mongodb的路徑下:cd E:\裝機軟件包\mongodb\bin
-
第二步纺涤,啟動:mongod --dbpath "E:\裝機軟件包\mongodb\data\db"
路徑是指mongodb的安裝路徑,通過以上3步就可以啟動了抠忘。
As you can see撩炊!第一個項目總是斷斷續(xù)續(xù),坎坎坷坷的崎脉,不過終究還是可以解決的拧咳,繼續(xù)加油吧!——2019.04.02