亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法將數據插入 MongoDb:

無法將數據插入 MongoDb:

郎朗坤 2021-06-11 23:26:29
無法在變量的幫助下將數據插入 mongodb 但如果我打印輸出并將其粘貼到 db.collection.insert_many(output) 則代碼運行正常并存儲數據但我直接使用 db.collection.insert_many(output_final) 它給我錯誤。請幫忙。import reimport jsonfrom selenium import webdriverfrom bs4 import  BeautifulSoupimport requestsfrom fake_useragent import  UserAgentimport pymongomyclient = pymongo.MongoClient("mongodb://localhost:27017/")db = myclient["db_db"]ua          = UserAgent()header      = {'user-agent':ua.chrome}driver      = webdriver.Chrome('C:/Users/MUNTAZIR/Downloads/Compressed/chromedriver_win32/chromedriver.exe')driver.get('https://www.eduvision.edu.pk/scholarships/index.php?authority=1&level=4&field=1&cat=2&type=1')# tr = driver.find_element_by_id('ctl00_ctl42_g_7f68baae_5353_4bdd_bfe1_b88e3367234f_csr1_table')soup = BeautifulSoup(driver.page_source, 'lxml')scholar = soup.findAll("div", {"class": "card-content col-xs-12"})s_output1 = ""for s in scholar[0:1]:        title=s.findAll("h2")[0].text        desc = s.findAll("div", {"class": "text"})[0].text.replace("\n", "").replace('"','')        url = "https://www.eduvision.edu.pk/scholarships/" + s.a['href']        type= "Higher Education Commission"        # print(type +"\n" +title +"\n" +desc +"\n" +url +"\n")        s_output1 = ("{""\n"             '"type"' + ":" + '" ' + type + ' ",' + "\n"             '"title"' + ":" + '" ' + title + ' ",' + "\n"             '"url"' + ":" + '" ' + url + ' ",' + "\n"             '"description"' + ":" + '" ' + desc + ' "' + "\n"             "}""\n"             )
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 293 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號