先上效果图上代码：from pyspider.libs.base_handler import * import pymongo class Handler(BaseHandler): crawl_config = { } client = pymongo.MongoClient('localhost') db = client['TripAdvise'] @every(minutes=24 * 60) def on_start(self): self.crawl('https://www.tripadvisor.cn/Attractions-g186338-Activities-c47-London_England.html',callback=self.index_page, validate_cert=False) @config(age=10 * 24 * 60 * 60) def index_page(self, response): for each in response.doc('div.listing_title > a').items(): self.crawl(each.attr.href, callback=self.detail_page, validate_cert=False) # 翻页 next = response.doc('.pagination .nav.next').attr.href self.crawl(next, callback=self.index_page, validate_cert=False) @config(priority=2) def detail_page(self, response): url = response.url name = response.doc('.h1').text() rating = response.doc(' div.ratingContainer > a > span').text() garde = response.doc('div.section.rating > span').text() address = response.doc('.contactInfo > .address').text() phone = response.doc('div.contact > div.contactType.phone.is-hidden-mobile > div').text() opening = response.doc('div.prw_rup.prw_common_atf_header_bl_responsive.headerBL > div > span').text() introduction = response.doc('.centerWell > div > div > div > div > div > span').text() return { "url": url, "name": name, "rating": rating, 'garde': garde, "address": address, "phone": phone, "opening": opening, "introduction": introduction } def on_result(self, result): if result: self.save_to_mongo(result) def save_to_mongo(self, result): if self.db['london'].insert(result): print('保存到MongoDB成功', result)参考：https://cuiqingcai.com/8317.html
先奉上代码：# 如果使用PhantomJS则selenium版本只能2.48.0及以下 from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC import time import re from pyquery import PyQuery as py import pymongo MONGO_URL='localhost' MONGO_DB='taobao' MONGO_TABLE='product' SERVICE_ARGS=['--load-images=false','--disk-cache=true'] # 不加载图片，开启缓存 client = pymongo.MongoClient(MONGO_URL, connect=False) db=client[MONGO_DB] # browser = webdriver.Chrome() browser = webdriver.PhantomJS(service_args=SERVICE_ARGS) browser.set_window_size(1400,900) #设置窗口大小，防止元素位置改变 wait = WebDriverWait(browser, 15) def search(): # 执行搜索后跳转到登录界面--选择微博登录-（淘宝要绑定微博，微博登录要取消双重登录验证） try: browser.get("https://www.taobao.com/") print('正在搜索') input = wait.until( EC.presence_of_element_located((By.CSS_SELECTOR, "#q")) ) # 输入框 submit = wait.until( EC.element_to_be_clickable((By.CSS_SELECTOR, "#J_TSearchForm > div.search-button > button")) ) # 搜索按钮 input.send_keys('美食') time.sleep(1) submit.click() # 登录 print('正在登录') wait.until( EC.element_to_be_clickable((By.CSS_SELECTOR, "#J_Quick2Static")) ).click() # 点击密码登录 time.sleep(2) wait.until( EC.element_to_be_clickable((By.CSS_SELECTOR, "#J_OtherLogin > a.weibo-login")) ).click() # 选择微博登录 wait.until( EC.presence_of_element_located((By.CSS_SELECTOR, "#pl_login_logged > div > div:nth-child(2) > div > input")) ).send_keys(' ') # 输入账号 time.sleep(2) wait.until( EC.presence_of_element_located((By.CSS_SELECTOR, "#pl_login_logged > div > div:nth-child(3) > div > input")) ).send_keys(' ') # 输入密码 time.sleep(2) wait.until( EC.element_to_be_clickable( (By.CSS_SELECTOR, "#pl_login_logged > div > div:nth-child(7) > div:nth-child(1) > a > span")) ).click() # 点击登录按钮 time.sleep(5) total = wait.until( EC.presence_of_element_located((By.CSS_SELECTOR, "#mainsrp-pager > div > div > div > div.total")) ) print('登录成功') get_prodects() return total.text except TimeoutError: search() # 翻页 def next_page(page_number): print('正在翻到第'+str(page_number)+'页') try: input = wait.until( EC.presence_of_element_located((By.CSS_SELECTOR, "#mainsrp-pager > div > div > div > div.form > input")) ) # 输入页数 submit = wait.until( EC.element_to_be_clickable((By.CSS_SELECTOR, "#mainsrp-pager > div > div > div > div.form > span.btn.J_Submit")) ) # 确定按钮 input.clear() input.send_keys(page_number) time.sleep(2) submit.click() wait.until( # 判断元素中是否存在指定的文本 判断当前高亮页码的序号是否是page_number li.item.active EC.text_to_be_present_in_element((By.CSS_SELECTOR,'#mainsrp-pager > div > div > div > ul > li.item.active > span'),str(page_number)) ) get_prodects() except TimeoutError: next_page(page_number) # 提取数据 def get_prodects(): print('正在提取数据') wait.until( EC.presence_of_element_located((By.CSS_SELECTOR,'#mainsrp-itemlist .items .item')) ) html=browser.page_source # 获取网页源代码 doc=py(html) items=doc('#mainsrp-itemlist .items .item').items() for item in items: product={ 'image':item.find('.pic .img').attr('src'), 'price':item.find('.price').text(), 'deal':item.find('.deal-cnt').text()[:-3], 'title':item.find('.title').text(), 'shop':item.find('.shop').text(), 'location':item.find('.location').text() } # print(product) save_to_mongo(product) def save_to_mongo(result): try: if db[MONGO_TABLE].insert(result): print("存储到MongoDB成功", result) except Exception: print("存储到MongoDB失败", result) def main(): total=search() total=int(re.compile('(\d+)').search(total).group(1)) # 把str强转为int # print(total) for i in range(2,total+1): next_page(i) browser.close() if __name__ == '__main__': main() 结果如下："C:\Program Files\Python\Python38\python.exe" E:/PycharmProjects/test/爬虫/淘宝美食/TaoBaoSpider.py 正在搜索 正在登录 登录成功 正在提取数据 E:/PycharmProjects/test/爬虫/淘宝美食/TaoBaoSpider.py:117: DeprecationWarning: insert is deprecated. Use insert_one or insert_many instead. if db[MONGO_TABLE].insert(result): 存储到MongoDB成功 {'image': '//g-search1.alicdn.com/img/bao/uploaded/i4/imgextra/i3/211060109/O1CN01g5A8VZ1Cfxk1wE0a8_!!0-saturn_solar.jpg_230x230.jpg', 'price': '¥59.80', 'deal': '6000+', 'title': '山东特产酱牛肉卤牛肉熟食五香真空480g健身牛肉牛腱肉即食小包装', 'shop': '日彤旗舰店', 'location': '山东 青岛', '_id': ObjectId('5e65b817070577c77949f239')} 存储到MongoDB成功 {'image': '//g-search1.alicdn.com/img/bao/uploaded/i4/i1/1690440456/O1CN01LNTXpC1FEtBiIC6yB_!!0-item_pic.jpg_230x230.jpg', 'price': '¥44.80', 'deal': '3.5万+', 'title': '友臣正宗肉松饼整箱休闲早零食充饥夜宵特产糕点美食营养食品面包', 'shop': '友臣旗舰店', 'location': '福建 泉州', '_id': ObjectId('5e65b817070577c77949f23a')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i2/475325704/O1CN01SoS4Ez1s0TkMD1y5E_!!0-item_pic.jpg_230x230.jpg', 'price': '¥10.90', 'deal': '7.5万+', 'title': '知味观艾草青团网红美食咸蛋黄肉松糯米团子杭州特产糕点小吃零食', 'shop': '知味观官方旗舰店', 'location': '浙江 杭州', '_id': ObjectId('5e65b817070577c77949f23b')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i3/2780349775/O1CN01fdbBay2M507ViTO7T_!!0-item_pic.jpg_230x230.jpg', 'price': '¥19.90', 'deal': '781', 'title': '安徽特产正宗黄山烧饼60个梅干菜扣肉饼手工美食小吃零食糕点', 'shop': '徽味和旗舰店', 'location': '安徽 黄山', '_id': ObjectId('5e65b818070577c77949f23c')} 存储到MongoDB成功 {'image': '//g-search2.alicdn.com/img/bao/uploaded/i4/i1/2901136168/O1CN01ONmRqA1vQzVLiJB2S_!!0-item_pic.jpg_230x230.jpg', 'price': '¥171.00', 'deal': '4178', 'title': '美珍香迷你金钱烧烤猪肉200g+迷你休闲烧烤猪肉200g小吃零食美食', 'shop': '美珍香旗舰店', 'location': '上海', '_id': ObjectId('5e65b818070577c77949f23d')} 存储到MongoDB成功 {'image': '//g-search2.alicdn.com/img/bao/uploaded/i4/i1/725677994/O1CN01C9jVrG28vIjnT4bsM_!!725677994-0-sm.jpg_230x230.jpg', 'price': '¥125.00', 'deal': '4115', 'title': '科尔沁手撕风干牛肉干400g原味内蒙古特产牛肉干美食零食小吃', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65b818070577c77949f23e')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i2/2780349775/O1CN01blLMR12M506FU8JES_!!0-item_pic.jpg_230x230.jpg', 'price': '¥19.90', 'deal': '1192', 'title': '咸海鸭蛋黄酥雪媚娘12枚早餐面包网红美食糕点心零食小吃休闲食品', 'shop': '徽味和旗舰店', 'location': '安徽 黄山', '_id': ObjectId('5e65b818070577c77949f23f')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i3/3282604381/O1CN01X6NZOS1iEXkd6R3wY_!!0-item_pic.jpg_230x230.jpg', 'price': '¥89.00', 'deal': '1.0万+', 'title': '轩妈家蛋黄酥2盒 红豆味雪媚娘麻薯新鲜糕点美食网红零食小吃早餐', 'shop': '轩妈食品旗舰店', 'location': '广西 南宁', '_id': ObjectId('5e65b818070577c77949f240')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i3/3282604381/O1CN01d3TQvV1iEXjene2EF_!!0-item_pic.jpg_230x230.jpg', 'price': '¥65.80', 'deal': '2.5万+', 'title': '轩妈家蛋黄酥4种口味组合混合装糕点点心美食零食小吃早餐食品', 'shop': '轩妈食品旗舰店', 'location': '广西 南宁', '_id': ObjectId('5e65b818070577c77949f241')} 存储到MongoDB成功 {'image': '//g-search1.alicdn.com/img/bao/uploaded/i4/i2/628189716/O1CN0118GTCN2LdylCslxQ3_!!0-item_pic.jpg_230x230.jpg', 'price': '¥38.90', 'deal': '1.5万+', 'title': '【百草味-肉松饼1kg】网红休闲零食特色小吃美食点心传统', 'shop': '百草味旗舰店', 'location': '浙江 杭州', '_id': ObjectId('5e65b818070577c77949f242')} 存储到MongoDB成功 {'image': '//g-search2.alicdn.com/img/bao/uploaded/i4/i3/725677994/O1CN01T834nB28vIjlZDD1k_!!725677994-0-sm.jpg_230x230.jpg', 'price': '¥59.90', 'deal': '2561', 'title': '好丽友薯愿5连包休闲膨化薯片礼包新老包装饼干美食小吃随机发货', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65b818070577c77949f243')} 存储到MongoDB成功 {'image': '//g-search2.alicdn.com/img/bao/uploaded/i4/i4/3017400344/O1CN01MXwZHa1EPapinEAtp_!!0-item_pic.jpg_230x230.jpg', 'price': '¥64.50', 'deal': '6.0万+', 'title': '好欢螺螺蛳粉柳州特产美食酸辣粉300gx5袋螺狮粉速食方便面米线', 'shop': '好欢螺旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65b818070577c77949f244')} 存储到MongoDB成功 {'image': None, 'price': '¥29.90', 'deal': '10万+', 'title': '满减【三只松鼠_蜀香牛肉100g】休闲零食小吃肉脯特产牛肉干美食', 'shop': '三只松鼠旗舰店', 'location': '安徽 芜湖', '_id': ObjectId('5e65b818070577c77949f245')} 存储到MongoDB成功 {'image': None, 'price': '¥69.90', 'deal': '1422', 'title': '满299减200丨自贡冷吃牛肉120g肖三婆四川麻辣牛肉干美食真空熟食', 'shop': '肖三婆旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65b818070577c77949f246')} 存储到MongoDB成功 {'image': None, 'price': '¥25.90', 'deal': '6.5万+', 'title': '【良品铺子-猪肉脯200g】零食小吃肉干网红休闲食品美食小包装', 'shop': '良品铺子旗舰店', 'location': '广东 广州', '_id': ObjectId('5e65b818070577c77949f247')} 存储到MongoDB成功 {'image': None, 'price': '¥119.80', 'deal': '1166', 'title': '【周黑鸭旗舰店_锁鲜】气调盒装卤鸭舌150g*2 美食特产零食品小吃', 'shop': '周黑鸭食品旗舰店', 'location': '湖北 武汉', '_id': ObjectId('5e65b818070577c77949f248')} 存储到MongoDB成功 {'image': None, 'price': '¥118.00', 'deal': '2082', 'title': '李村猪肉脂渣香酥油渣干炸五花肉粕青岛特产小吃美食肉类生酮零食', 'shop': '李村旗舰店', 'location': '山东 青岛', '_id': ObjectId('5e65b818070577c77949f249')} 存储到MongoDB成功 {'image': None, 'price': '¥79.00', 'deal': '2060', 'title': '科尔沁超干牛肉干175g原味内蒙古风干牛肉干草原特产手撕零食美食', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65b818070577c77949f24a')} 存储到MongoDB成功 {'image': None, 'price': '¥74.50', 'deal': '2.0万+', 'title': '好欢螺螺蛳粉柳州美食螺丝粉400g*5袋螺狮粉速食懒人方便面非泡面', 'shop': '好欢螺旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65b818070577c77949f24b')} 存储到MongoDB成功 {'image': None, 'price': '¥39.90', 'deal': '6000+', 'title': '好丽友呀土豆9连包超值礼包实惠家庭装休闲膨化薯片饼干美食小吃', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65b818070577c77949f24c')} 存储到MongoDB成功 {'image': None, 'price': '¥288.00', 'deal': '8', 'title': '【周黑鸭门店同款】熹礼礼盒920g 含整鸭 美食特产零食大礼包礼盒', 'shop': '周黑鸭食品旗舰店', 'location': '湖北 武汉', '_id': ObjectId('5e65b818070577c77949f24d')} 存储到MongoDB成功 {'image': None, 'price': '¥73.50', 'deal': '2918', 'title': '友臣肉松饼2.1kg营养早餐点心美食晚上解饿零食糕点整箱批发面包', 'shop': '友臣旗舰店', 'location': '福建 泉州', '_id': ObjectId('5e65b818070577c77949f24e')} 存储到MongoDB成功 {'image': None, 'price': '¥29.80', 'deal': '5.5万+', 'title': '卫龙大礼包辣条亲嘴烧豆干麻辣味整箱儿时小吃休闲美食网红零食品', 'shop': '猫诚旗舰店', 'location': '安徽 合肥', '_id': ObjectId('5e65b818070577c77949f24f')} 存储到MongoDB成功 {'image': None, 'price': '¥36.80', 'deal': '1.5万+', 'title': '蛋黄酥海鸭蛋零食小吃网红充饥夜宵特产美食糕点点心整箱休闲食品', 'shop': '比比赞旗舰店', 'location': '福建 厦门', '_id': ObjectId('5e65b818070577c77949f250')} 存储到MongoDB成功 {'image': None, 'price': '¥69.90', 'deal': '1052', 'title': '满299减200丨肖三婆无骨鸭掌150g麻辣去脱骨鸭爪四川特产卤味美食', 'shop': '肖三婆旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65b818070577c77949f251')} 存储到MongoDB成功 {'image': None, 'price': '¥45.90', 'deal': '1847', 'title': '阿宽白家红油面皮12袋1260g特色小吃方便面非火鸡面成都特色美食', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65b818070577c77949f252')} 存储到MongoDB成功 {'image': None, 'price': '¥64.90', 'deal': '1099', 'title': '盼盼肉松饼整箱营养早餐糕点小吃面包特产美食网红小零食2100g', 'shop': '盼盼食品官方旗舰店', 'location': '河南 漯河', '_id': ObjectId('5e65b818070577c77949f253')} 存储到MongoDB成功 {'image': None, 'price': '¥189.00', 'deal': '1068', 'title': '散装【卫龙旗舰店】魔芋爽整箱辣条毛肚素食香麻辣网红美食小袋装', 'shop': '卫龙食品旗舰店', 'location': '河南 漯河', '_id': ObjectId('5e65b818070577c77949f254')} 存储到MongoDB成功 {'image': None, 'price': '¥123.00', 'deal': '2597', 'title': '【德州扒鸡旗舰店】德州扒鸡正宗鸡爪熟食零食美食德州 扒鸡600g3', 'shop': '德州扒鸡旗舰店', 'location': '山东 德州', '_id': ObjectId('5e65b818070577c77949f255')} 存储到MongoDB成功 {'image': None, 'price': '¥68.00', 'deal': '222', 'title': '沈大成糕点桂花拉糕2盒 上海特产老字号 糯米糕点心 网红美食', 'shop': '沈大成旗舰店', 'location': '上海', '_id': ObjectId('5e65b818070577c77949f256')} 存储到MongoDB成功 {'image': None, 'price': '¥92.90', 'deal': '1752', 'title': '廖记棒棒鸡无骨鸡爪两份920g 四川特色小吃麻辣无骨鸡爪零食美食', 'shop': '廖记棒棒鸡旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65b818070577c77949f257')} 存储到MongoDB成功 {'image': None, 'price': '¥39.90', 'deal': '5000+', 'title': '嘉华鲜花饼云腿小饼12枚礼袋云南特产零食小吃美食早餐传统糕点心', 'shop': '嘉华食品旗舰店', 'location': '云南 昆明', '_id': ObjectId('5e65b818070577c77949f258')} 存储到MongoDB成功 {'image': None, 'price': '¥19.90', 'deal': '3.5万+', 'title': '【良品铺子-甜辣鸭脖子190g】卤味零食小吃美食休闲食品小包装', 'shop': '良品铺子旗舰店', 'location': '广东 广州', '_id': ObjectId('5e65b818070577c77949f259')} 存储到MongoDB成功 {'image': None, 'price': '¥56.00', 'deal': '2793', 'title': '桂花鸭南京盐水鸭1000g正宗江苏特产年货美食板鸭咸水鸭真空熟食', 'shop': '桂花鸭旗舰店', 'location': '江苏 南京', '_id': ObjectId('5e65b818070577c77949f25a')} 存储到MongoDB成功 {'image': None, 'price': '¥84.90', 'deal': '2052', 'title': '桃李天然酵母面包1800g营养早餐零食美食品手撕口袋面包蛋糕整箱', 'shop': '桃李食品旗舰店', 'location': '辽宁 沈阳', '_id': ObjectId('5e65b818070577c77949f25b')} 存储到MongoDB成功 {'image': None, 'price': '¥69.00', 'deal': '1547', 'title': '杨大爷五花腊肉500g四川美食特产腊肉农家自制烟熏肥咸肉柴火腊肉', 'shop': '杨大爷旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65b818070577c77949f25c')} 存储到MongoDB成功 {'image': None, 'price': '¥20.50', 'deal': '3508', 'title': '满减【三只松鼠_墨玉川式芝麻酥135g】美食早餐小吃点心休闲零食', 'shop': '三只松鼠旗舰店', 'location': '安徽 芜湖', '_id': ObjectId('5e65b818070577c77949f25d')} 存储到MongoDB成功 {'image': None, 'price': '¥69.90', 'deal': '1897', 'title': '双鱼猪肉脯400克靖江特产猪肉铺金奖猪肉干自然片老字号中华美食', 'shop': '双鱼食品旗舰店', 'location': '江苏 泰州', '_id': ObjectId('5e65b818070577c77949f25e')} 存储到MongoDB成功 {'image': None, 'price': '¥109.00', 'deal': '721', 'title': '桂花鸭南京盐水鸭+酱鸭2000g特产正宗美食送礼真空装熟食年货食品', 'shop': '桂花鸭旗舰店', 'location': '江苏 南京', '_id': ObjectId('5e65b818070577c77949f25f')} 存储到MongoDB成功 {'image': None, 'price': '¥29.90', 'deal': '3.0万+', 'title': '绝艺鸭货零食大礼包麻辣味网红小吃休闲食品充饥夜宵整箱散装美食', 'shop': '绝艺食品旗舰店', 'location': '湖南 长沙', '_id': ObjectId('5e65b818070577c77949f260')} 存储到MongoDB成功 {'image': None, 'price': '¥178.00', 'deal': '494', 'title': '修文鸭舌温州特产酱鸭舌酱卤鸭舌头原味美食小吃休闲零食净重480g', 'shop': '修文食品官方旗舰店', 'location': '浙江 温州', '_id': ObjectId('5e65b818070577c77949f261')} 存储到MongoDB成功 {'image': None, 'price': '¥29.90', 'deal': '4604', 'title': '来伊份虎皮蛋糕168gx2糕点零食奶香夹心蛋糕美食早餐软点心小包装', 'shop': '来伊份官方旗舰店', 'location': '上海', '_id': ObjectId('5e65b818070577c77949f262')} 存储到MongoDB成功 {'image': None, 'price': '¥121.00', 'deal': '1112', 'title': '【旗舰店】螺状元柳州螺蛳粉280g*10袋礼盒装特产美食广西螺丝粉', 'shop': '螺状元旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65b818070577c77949f263')} 存储到MongoDB成功 {'image': None, 'price': '¥36.90', 'deal': '1.0万+', 'title': '沈师傅鸡蛋干四川特产豆腐干成都美食豆干小吃零食休闲食品非150g', 'shop': '沈师傅旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65b818070577c77949f264')} 存储到MongoDB成功 {'image': None, 'price': '¥29.90', 'deal': '1.0万+', 'title': '五芳斋绿豆糕伴手礼桂花糕办公室点心休闲小吃零食绿豆饼好吃美食', 'shop': '五芳斋官方旗舰店', 'location': '浙江 嘉兴', '_id': ObjectId('5e65b818070577c77949f265')} 存储到MongoDB成功 {'image': None, 'price': '¥60.00', 'deal': '1566', 'title': '奇多粟米棒休闲食品小吃零食整箱混装90*12童年回忆怀旧网红美食', 'shop': '百事集团官方旗舰店', 'location': '江苏 无锡', '_id': ObjectId('5e65b818070577c77949f266')} 存储到MongoDB成功 {'image': None, 'price': '¥32.90', 'deal': '5000+', 'title': '稻香村牛舌饼360G*2好吃的传统特产特色糕点心酥皮美食小吃零食', 'shop': '稻香村食品旗舰店', 'location': '北京', '_id': ObjectId('5e65b818070577c77949f267')} 存储到MongoDB成功 {'image': None, 'price': '¥90.00', 'deal': '660', 'title': '美珍香芝士烧烤猪肉200g女生办公室零食网红特产小吃小孩肉类美食', 'shop': '美珍香旗舰店', 'location': '上海', '_id': ObjectId('5e65b818070577c77949f268')} 正在翻到第2页 正在提取数据 存储到MongoDB成功 {'image': '//g-search1.alicdn.com/img/bao/uploaded/i4/imgextra/i2/355210051/O1CN010bqXZy1CFOmnpz1vu_!!0-saturn_solar.jpg_230x230.jpg', 'price': '¥59.00', 'deal': '900', 'title': '王小余外卖料理包盖浇饭煲仔饭快餐方便菜肴包简餐冷冻速食批发', 'shop': '王小余旗舰店', 'location': '湖南 长沙', '_id': ObjectId('5e65b81d070577c77949f269')} 存储到MongoDB成功 {'image': '//g-search1.alicdn.com/img/bao/uploaded/i4/imgextra/i3/31955429/O1CN01DUqXSW1pyWpUevs0i_!!0-saturn_solar.jpg_230x230.jpg', 'price': '¥39.00', 'deal': '1017', 'title': '礼记 杏仁饼 澳门礼记饼家 粒粒澳门手信特产圆罐美食零食410g', 'shop': '澳门礼记饼家旗舰店', 'location': '广东 珠海', '_id': ObjectId('5e65b81d070577c77949f26a')} 存储到MongoDB成功 {'image': '//g-search1.alicdn.com/img/bao/uploaded/i4/imgextra/i4/128920586/TB2AODfqOOYBuNjSsD4XXbSkFXa_!!0-saturn_solar.jpg_230x230.jpg', 'price': '¥45.80', 'deal': '9500+', 'title': '正宗香肠腊肠咸甜味纯肉安徽农家自制灌肠手工土特产风干特色腊味', 'shop': '挑货佬旗舰店', 'location': '安徽 合肥', '_id': ObjectId('5e65b81d070577c77949f26b')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i1/2112833578/O1CN01vCskFZ1cIli65RWbO_!!0-item_pic.jpg_230x230.jpg', 'price': '¥69.90', 'deal': '705', 'title': '港荣奶香蒸蛋糕点点心 整箱营养早餐零食品美食手撕小吃面包邮', 'shop': '港荣食品旗舰店', 'location': '广东 揭阳', '_id': ObjectId('5e65b81d070577c77949f26c')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i4/1719214398/O1CN019NyQD71iMKTy0GvDt_!!0-item_pic.jpg_230x230.jpg', 'price': '¥49.00', 'deal': '2395', 'title': '【买二送一】沈大成糕点青芝士团网红零食小吃老字号美食上海特产', 'shop': '沈大成旗舰店', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f26d')} 存储到MongoDB成功 {'image': '//g-search2.alicdn.com/img/bao/uploaded/i4/i4/2200757237600/O1CN01b7qOBA260qfUahx1r_!!0-item_pic.jpg_230x230.jpg', 'price': '¥99.00', 'deal': '', 'title': '科尔沁手撕风干牛肉干400g原味内蒙古特产牛肉干美食零食小吃', 'shop': '天猫会员店', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f26e')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i2/3417098543/O1CN010KZu3a2CykB5pWFhh_!!0-item_pic.jpg_230x230.jpg', 'price': '¥37.90', 'deal': '2.5万+', 'title': '【顺丰快递】柳州螺蛳粉家柳广西特产螺狮美食300g*5包方便酸辣粉', 'shop': '家柳旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65b81d070577c77949f26f')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i1/2653324232/O1CN01qDJHEK1h8IjkVPXYa_!!0-item_pic.jpg_230x230.jpg', 'price': '¥52.00', 'deal': '6000+', 'title': '沈厅 周庄特产沈万三家蹄髈1000g猪蹄酱肘子蹄膀肉类熟食卤味美食', 'shop': '沈厅旗舰店', 'location': '江苏 苏州', '_id': ObjectId('5e65b81d070577c77949f270')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i1/475325704/O1CN01euNxPt1s0TjwGTYLb_!!0-item_pic.jpg_230x230.jpg', 'price': '¥86.70', 'deal': '257', 'title': '满减【知味观杭州酱鸭】酱板鸭浙江特产鸭肉小吃美食卤味零食熟食', 'shop': '知味观官方旗舰店', 'location': '浙江 杭州', '_id': ObjectId('5e65b81d070577c77949f271')} 存储到MongoDB成功 {'image': '//g-search1.alicdn.com/img/bao/uploaded/i4/i1/2780349775/TB2kLjErxSYBuNjSsphXXbGvVXa_!!2780349775-0-item_pic.jpg_230x230.jpg', 'price': '¥59.90', 'deal': '2', 'title': '正宗安徽特产糯米锅巴2400g 传统美食零食小吃批发 大份量', 'shop': '徽味和旗舰店', 'location': '安徽 黄山', '_id': ObjectId('5e65b81d070577c77949f272')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i3/2780349775/O1CN01vNKwyC2M507TWBZot_!!0-item_pic.jpg_230x230.jpg', 'price': '¥24.90', 'deal': '21', 'title': '徽味和 零食小吃营养办公室休闲美食芝士小脆条好吃糕点2罐', 'shop': '徽味和旗舰店', 'location': '安徽 黄山', '_id': ObjectId('5e65b81d070577c77949f273')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i3/3017400344/O1CN01uenr341EPappYcz5V_!!0-item_pic.jpg_230x230.jpg', 'price': '¥77.40', 'deal': '3.5万+', 'title': '好欢螺螺蛳粉300g*6袋柳州特产螺狮粉美食螺丝粉煮水方便面酸辣粉', 'shop': '好欢螺旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65b81d070577c77949f274')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i4/392147177/O1CN01fiVlzN22t78xBwRdQ_!!0-item_pic.jpg_230x230.jpg', 'price': '¥59.90', 'deal': '5000+', 'title': '【周黑鸭旗舰店_锁鲜】气调盒装卤鸭舌150g 美食特产食品零食小吃', 'shop': '周黑鸭食品旗舰店', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f275')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i1/392147177/O1CN01AngkGR22t79TKoYq1_!!0-item_pic.jpg_230x230.jpg', 'price': '¥49.90', 'deal': '2.0万+', 'title': '【周黑鸭旗舰店】锁鲜卤鸭脖200g鸭锁骨240g美食特产零食小吃熟食', 'shop': '周黑鸭食品旗舰店', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f276')} 存储到MongoDB成功 {'image': '//g-search1.alicdn.com/img/bao/uploaded/i4/i1/3282604381/O1CN01xnrcQx1iEXjdPvrjc_!!0-item_pic.jpg_230x230.jpg', 'price': '¥39.90', 'deal': '1.5万+', 'title': '轩妈家芝士酥4枚 蛋黄酥芝士雪媚娘麻薯软糯新鲜糕点美食早餐零食', 'shop': '轩妈食品旗舰店', 'location': '广西 南宁', '_id': ObjectId('5e65b81d070577c77949f277')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i4/2453625574/O1CN014YbSCz1r2wFmsUoev_!!0-item_pic.jpg_230x230.jpg', 'price': '¥105.00', 'deal': '310', 'title': '满299减200丨香辣卤鸭舌头四川美食地方特色小零食下酒菜网红小吃', 'shop': '肖三婆旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65b81d070577c77949f278')} 存储到MongoDB成功 {'image': None, 'price': '¥48.00', 'deal': '7000+', 'title': '轩妈家蛋黄酥芝士冰沙味55g*6枚 雪媚娘夹心馅美食糕点早餐零食', 'shop': '轩妈食品旗舰店', 'location': '广西 南宁', '_id': ObjectId('5e65b81d070577c77949f279')} 存储到MongoDB成功 {'image': None, 'price': '¥56.80', 'deal': '1253', 'title': '草原今朝风干牛肉干原味106g内蒙古特产新鲜真空包装休闲零食美食', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f27a')} 存储到MongoDB成功 {'image': None, 'price': '¥22.90', 'deal': '9.5万+', 'title': '三只松鼠蜀香麻辣味牛肉干100g麻辣小零食熟食特产牛肉粒美食小吃', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f27b')} 存储到MongoDB成功 {'image': None, 'price': '¥19.90', 'deal': '3.5万+', 'title': '【良品铺子-甜辣鸭脖子190g】卤味零食小吃美食休闲食品小包装', 'shop': '良品铺子旗舰店', 'location': '广东 广州', '_id': ObjectId('5e65b81d070577c77949f27c')} 存储到MongoDB成功 {'image': None, 'price': '¥44.70', 'deal': '1.5万+', 'title': '好欢螺螺蛳粉柳州美食特产螺狮粉400g*3袋螺丝粉速食方便面酸辣粉', 'shop': '好欢螺旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65b81d070577c77949f27d')} 存储到MongoDB成功 {'image': None, 'price': '¥208.00', 'deal': '22', 'title': '【满299减200】肖三婆腊猪尾巴农家自制腊味手工美食烟熏腊肉香肠', 'shop': '肖三婆旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65b81d070577c77949f27e')} 存储到MongoDB成功 {'image': None, 'price': '¥17.90', 'deal': '4564', 'title': '满减【三只松鼠_白玉川式花生酥135g】美食早餐小吃点心休闲零食', 'shop': '三只松鼠旗舰店', 'location': '安徽 芜湖', '_id': ObjectId('5e65b81d070577c77949f27f')} 存储到MongoDB成功 {'image': None, 'price': '¥90.00', 'deal': '302', 'title': '友臣肉松饼办公室零食特产早餐整箱小吃糕点1250g*2箱美食', 'shop': '友臣旗舰店', 'location': '福建 泉州', '_id': ObjectId('5e65b81d070577c77949f280')} 存储到MongoDB成功 {'image': None, 'price': '¥66.00', 'deal': '1315', 'title': '桂花鸭南京特产盐水鸭正宗银桂流香真空板鸭美食熟食品咸水鸭1kg', 'shop': '桂花鸭旗舰店', 'location': '江苏 南京', '_id': ObjectId('5e65b81d070577c77949f281')} 存储到MongoDB成功 {'image': None, 'price': '¥29.90', 'deal': '400', 'title': '上好旺香甜玉米酥1斤花生芝麻点心特产美食小吃早餐零食饼干糕点', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f282')} 存储到MongoDB成功 {'image': None, 'price': '¥17.20', 'deal': '1.0万+', 'title': '【百草味】麻薯(抹茶味)210g*2袋装 糕点小吃美食 早餐休闲零食', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f283')} 存储到MongoDB成功 {'image': None, 'price': '¥31.90', 'deal': '820', 'title': '蜜诺达法式咸芝士西饼150g*2罐曲奇饼干烘焙零食休闲小吃美食早餐', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f284')} 存储到MongoDB成功 {'image': None, 'price': '¥65.00', 'deal': '5.5万+', 'title': '螺状元柳州螺蛳粉特产美食方便面速食螺狮粉米线广西螺丝粉', 'shop': '螺状元旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65b81d070577c77949f285')} 存储到MongoDB成功 {'image': None, 'price': '¥29.00', 'deal': '4623', 'title': '沈大成糕点桂花拉糕上海特产老字号传统手工糕点心网红美食桂花糕', 'shop': '沈大成旗舰店', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f286')} 存储到MongoDB成功 {'image': None, 'price': '¥1550.00', 'deal': '42', 'title': 'Hape 美食家超能大厨房大型仿真厨房过家家玩具女孩益智玩具', 'shop': '天天装饰店', 'location': '江苏 苏州', '_id': ObjectId('5e65b81d070577c77949f287')} 存储到MongoDB成功 {'image': None, 'price': '¥115.00', 'deal': '6000+', 'title': '螺蛳粉螺霸王螺丝粉广西柳州正宗美食特产10包礼盒装整箱螺狮粉', 'shop': '广西御品香食品有限公司店', 'location': '广西 柳州', '_id': ObjectId('5e65b81d070577c77949f288')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i2/1692258071/O1CN0150relj29UZEc14hL8_!!0-item_pic.jpg_230x230.jpg', 'price': '¥28.90', 'deal': '1653', 'title': '稻香村芝麻瓦片450g好吃传统糕点点心饼干休闲零食品美食特产小吃', 'shop': '稻香村食品旗舰店', 'location': '北京', '_id': ObjectId('5e65b81d070577c77949f289')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i2/1893751150/O1CN01Nj0a4i1KMk3w3iaWc_!!0-item_pic.jpg_230x230.jpg', 'price': '¥44.50', 'deal': '1749', 'title': '奇多粟米棒食品小吃零食礼包整箱牛排火鸡味60g*12包怀旧美食', 'shop': '百事集团官方旗舰店', 'location': '江苏 无锡', '_id': ObjectId('5e65b81d070577c77949f28a')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i1/739302607/O1CN010g60Ei1V8383BrfNA_!!0-item_pic.jpg_230x230.jpg', 'price': '¥158.60', 'deal': '509', 'title': '乐奈网红零食大礼包女生组合一整箱多口味混装办公室休闲小吃美食', 'shop': '乐奈旗舰店', 'location': '江苏 苏州', '_id': ObjectId('5e65b81d070577c77949f28b')} 存储到MongoDB成功 {'image': '//g-search1.alicdn.com/img/bao/uploaded/i4/i3/1023528406/O1CN01HhlFtI2BxzukCu07L_!!0-item_pic.jpg_230x230.jpg', 'price': '¥108.00', 'deal': '416', 'title': '广州酒家天天向上糕点零食礼包礼盒广东美食小吃饼干节日送礼手信', 'shop': '广州酒家旗舰店', 'location': '广东 广州', '_id': ObjectId('5e65b81d070577c77949f28c')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i3/2033032140/O1CN01GNrsff1RgA49Axs63_!!0-item_pic.jpg_230x230.jpg', 'price': '¥55.00', 'deal': '1517', 'title': '杏花楼老字号上海美食传统熟食咸鸡即食卤味白鸡切盐水鸡真空', 'shop': '杏花楼食品旗舰店', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f28d')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i3/3087037216/O1CN01H2Zloe23Ayb8fSOLI_!!0-item_pic.jpg_230x230.jpg', 'price': '¥34.90', 'deal': '1.5万+', 'title': '螺状元柳州螺蛳粉少女粉特产美食螺狮粉辣方便面速食广西螺丝粉', 'shop': '螺状元旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65b81d070577c77949f28e')} 存储到MongoDB成功 {'image': '//g-search2.alicdn.com/img/bao/uploaded/i4/i1/1690440456/O1CN01smbxix1FEtBBWAS1F_!!0-item_pic.jpg_230x230.jpg', 'price': '¥19.90', 'deal': '9000+', 'title': '友臣散装肉松饼500g营养早餐糕点网红零食美食小吃休闲食品点心', 'shop': '友臣旗舰店', 'location': '福建 泉州', '_id': ObjectId('5e65b81d070577c77949f28f')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i1/4010105128/O1CN01JeN8N51nkfbv6BZzk_!!0-item_pic.jpg_230x230.jpg', 'price': '¥69.90', 'deal': '1006', 'title': '嗨吃家酸辣粉桶装整箱12桶重庆网红美食嗨吃家红薯粉丝方便速食', 'shop': '川之味食品专营店', 'location': '河南 郑州', '_id': ObjectId('5e65b81d070577c77949f290')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i1/619123122/O1CN01arHaI81Yvv6WAes8F_!!0-item_pic.jpg_230x230.jpg', 'price': '¥26.90', 'deal': '1.5万+', 'title': '【良品铺子-肉松饼380g】早餐糕点零食美食小吃休闲食品满减', 'shop': '良品铺子旗舰店', 'location': '广东 广州', '_id': ObjectId('5e65b81d070577c77949f291')} 存储到MongoDB成功 {'image': '//g-search2.alicdn.com/img/bao/uploaded/i4/i3/732501769/O1CN01tu2gBR1OwFECXHtB9_!!0-item_pic.jpg_230x230.jpg', 'price': '¥18.90', 'deal': '1923', 'title': '来伊份桃酥252g饼干传统糕点点心酥饼休闲零食小吃美食食品核桃酥', 'shop': '来伊份官方旗舰店', 'location': '上海', '_id': ObjectId('5e65b81d070577c77949f292')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i4/3477045551/O1CN01PUnfzV1qsP9IpGzgu_!!0-item_pic.jpg_230x230.jpg', 'price': '¥63.88', 'deal': '4155', 'title': '柳螺宗蛳螺蛳粉正宗柳州特产美食330g*5袋螺狮粉整箱礼盒装螺丝粉', 'shop': '柳螺宗蛳旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65b81d070577c77949f293')} 存储到MongoDB成功 {'image': '//g-search2.alicdn.com/img/bao/uploaded/i4/i2/1692258071/O1CN01lL4kNM29UZEeF0HzW_!!0-item_pic.jpg_230x230.jpg', 'price': '¥26.90', 'deal': '1776', 'title': '稻香村江米条260g*2特色传统好吃的特产80后怀旧美食小吃零食茶点', 'shop': '稻香村食品旗舰店', 'location': '北京', '_id': ObjectId('5e65b81d070577c77949f294')} 正在翻到第3页 进程已结束，退出代码 -1就是不知道为什么有的图片获取不到链接？不用PhantomJS就可以全部获取到。不用PhantomJS的时候{'image': '//g.alicdn.com/s.gif', 'price': '¥69.90', 'deal': '1422', 'title': '满299减200丨自贡冷吃牛肉120g肖三婆四川麻辣牛肉干美食真空熟食', 'shop': '肖三婆旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65bdbc60aa342626aa2447')}用PhantomJS的时候{'image': None, 'price': '¥69.90', 'deal': '1422', 'title': '满299减200丨自贡冷吃牛肉120g肖三婆四川麻辣牛肉干美食真空熟食', 'shop': '肖三婆旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65b818070577c77949f246')}对比发现可能是爬取速度太快没有加载出来gif图片，但是加入time.sleep(5)依然如此，这是可能是PhantomJS的一个bug，改用Chrome Headless模式（Chrome 59及以上）chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') browser = webdriver.Chrome(chrome_options=chrome_options)部分结果：存储到MongoDB成功 {'image': '//g-search1.alicdn.com/img/bao/uploaded/i4/imgextra/i3/211060109/O1CN01g5A8VZ1Cfxk1wE0a8_!!0-saturn_solar.jpg_180x180.jpg', 'price': '¥59.80', 'deal': '6000+', 'title': '山东特产酱牛肉卤牛肉熟食五香真空480g健身牛肉牛腱肉即食小包装', 'shop': '日彤旗舰店', 'location': '山东 青岛', '_id': ObjectId('5e65c110d162fe0e0bcd1a8f')} 存储到MongoDB成功 {'image': '//g-search2.alicdn.com/img/bao/uploaded/i4/i2/475325704/O1CN01SoS4Ez1s0TkMD1y5E_!!0-item_pic.jpg_180x180.jpg', 'price': '¥10.90', 'deal': '7.5万+', 'title': '知味观艾草青团网红美食咸蛋黄肉松糯米团子杭州特产糕点小吃零食', 'shop': '知味观官方旗舰店', 'location': '浙江 杭州', '_id': ObjectId('5e65c110d162fe0e0bcd1a90')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i1/475325704/O1CN01qUbxld1s0TkL8kzr4_!!0-item_pic.jpg_180x180.jpg', 'price': '¥19.90', 'deal': '8000+', 'title': '知味观绿豆糕杭州特产桂花绿豆饼糕点好吃的老式传统美食抹茶零食', 'shop': '知味观官方旗舰店', 'location': '浙江 杭州', '_id': ObjectId('5e65c110d162fe0e0bcd1a91')} 存储到MongoDB成功 {'image': '//g-search2.alicdn.com/img/bao/uploaded/i4/i3/2780349775/O1CN01fdbBay2M507ViTO7T_!!0-item_pic.jpg_180x180.jpg', 'price': '¥19.90', 'deal': '801', 'title': '安徽特产正宗黄山烧饼60个梅干菜扣肉饼手工美食小吃零食糕点', 'shop': '徽味和旗舰店', 'location': '安徽 黄山', '_id': ObjectId('5e65c110d162fe0e0bcd1a92')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i1/2901136168/O1CN01ONmRqA1vQzVLiJB2S_!!0-item_pic.jpg_180x180.jpg', 'price': '¥171.00', 'deal': '4299', 'title': '美珍香迷你金钱烧烤猪肉200g+迷你休闲烧烤猪肉200g小吃零食美食', 'shop': '美珍香旗舰店', 'location': '上海', '_id': ObjectId('5e65c110d162fe0e0bcd1a93')} 存储到MongoDB成功 {'image': '//g-search2.alicdn.com/img/bao/uploaded/i4/i1/725677994/O1CN01C9jVrG28vIjnT4bsM_!!725677994-0-sm.jpg_180x180.jpg', 'price': '¥139.00', 'deal': '4156', 'title': '科尔沁手撕风干牛肉干400g原味内蒙古特产牛肉干美食零食小吃', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65c110d162fe0e0bcd1a94')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i2/2780349775/O1CN01blLMR12M506FU8JES_!!0-item_pic.jpg_180x180.jpg', 'price': '¥19.90', 'deal': '1216', 'title': '咸海鸭蛋黄酥雪媚娘12枚早餐面包网红美食糕点心零食小吃休闲食品', 'shop': '徽味和旗舰店', 'location': '安徽 黄山', '_id': ObjectId('5e65c110d162fe0e0bcd1a95')} 存储到MongoDB成功 {'image': '//g-search3.alicdn.com/img/bao/uploaded/i4/i3/3282604381/O1CN018msmXw1iEXkerMyhB_!!3282604381.jpg_180x180.jpg', 'price': '¥89.00', 'deal': '1.0万+', 'title': '轩妈家蛋黄酥2盒 红豆味雪媚娘麻薯新鲜糕点美食网红零食小吃早餐', 'shop': '轩妈食品旗舰店', 'location': '广西 南宁', '_id': ObjectId('5e65c110d162fe0e0bcd1a96')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥65.80', 'deal': '2.5万+', 'title': '轩妈家蛋黄酥4种口味组合混合装糕点点心美食零食小吃早餐食品', 'shop': '轩妈食品旗舰店', 'location': '广西 南宁', '_id': ObjectId('5e65c110d162fe0e0bcd1a97')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥44.80', 'deal': '3.5万+', 'title': '友臣正宗肉松饼整箱休闲早零食充饥夜宵特产糕点美食营养食品面包', 'shop': '友臣旗舰店', 'location': '福建 泉州', '_id': ObjectId('5e65c110d162fe0e0bcd1a98')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥38.90', 'deal': '1.5万+', 'title': '【百草味-肉松饼1kg】网红休闲零食特色小吃美食点心传统', 'shop': '百草味旗舰店', 'location': '浙江 杭州', '_id': ObjectId('5e65c110d162fe0e0bcd1a99')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥59.90', 'deal': '2569', 'title': '好丽友薯愿5连包休闲膨化薯片礼包新老包装饼干美食小吃随机发货', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65c110d162fe0e0bcd1a9a')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥64.50', 'deal': '6.0万+', 'title': '好欢螺螺蛳粉柳州特产美食酸辣粉300gx5袋螺狮粉速食方便面米线', 'shop': '好欢螺旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65c110d162fe0e0bcd1a9b')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥69.90', 'deal': '1440', 'title': '满299减200丨自贡冷吃牛肉120g肖三婆四川麻辣牛肉干美食真空熟食', 'shop': '肖三婆旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65c110d162fe0e0bcd1a9c')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥29.90', 'deal': '10万+', 'title': '满减【三只松鼠_蜀香牛肉100g】休闲零食小吃肉脯特产牛肉干美食', 'shop': '三只松鼠旗舰店', 'location': '安徽 芜湖', '_id': ObjectId('5e65c110d162fe0e0bcd1a9d')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥25.90', 'deal': '6.5万+', 'title': '【良品铺子-猪肉脯200g】零食小吃肉干网红休闲食品美食小包装', 'shop': '良品铺子旗舰店', 'location': '广东 广州', '_id': ObjectId('5e65c110d162fe0e0bcd1a9e')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥119.80', 'deal': '1184', 'title': '【周黑鸭旗舰店_锁鲜】气调盒装卤鸭舌150g*2 美食特产零食品小吃', 'shop': '周黑鸭食品旗舰店', 'location': '湖北 武汉', '_id': ObjectId('5e65c110d162fe0e0bcd1a9f')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥118.00', 'deal': '2100', 'title': '李村猪肉脂渣香酥油渣干炸五花肉粕青岛特产小吃美食肉类生酮零食', 'shop': '李村旗舰店', 'location': '山东 青岛', '_id': ObjectId('5e65c110d162fe0e0bcd1aa0')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥99.00', 'deal': '2054', 'title': '科尔沁超干牛肉干175g原味内蒙古风干牛肉干草原特产手撕零食美食', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65c110d162fe0e0bcd1aa1')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥59.00', 'deal': '6000+', 'title': '好丽友呀土豆9连包超值礼包实惠家庭装休闲膨化薯片饼干美食小吃', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65c110d162fe0e0bcd1aa2')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥74.50', 'deal': '2.0万+', 'title': '好欢螺螺蛳粉柳州美食螺丝粉400g*5袋螺狮粉速食懒人方便面非泡面', 'shop': '好欢螺旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65c110d162fe0e0bcd1aa3')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥288.00', 'deal': '8', 'title': '【周黑鸭门店同款】熹礼礼盒920g 含整鸭 美食特产零食大礼包礼盒', 'shop': '周黑鸭食品旗舰店', 'location': '湖北 武汉', '_id': ObjectId('5e65c110d162fe0e0bcd1aa4')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥73.50', 'deal': '2989', 'title': '友臣肉松饼2.1kg营养早餐点心美食晚上解饿零食糕点整箱批发面包', 'shop': '友臣旗舰店', 'location': '福建 泉州', '_id': ObjectId('5e65c110d162fe0e0bcd1aa5')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥36.80', 'deal': '1.5万+', 'title': '蛋黄酥海鸭蛋零食小吃网红充饥夜宵特产美食糕点点心整箱休闲食品', 'shop': '比比赞旗舰店', 'location': '福建 厦门', '_id': ObjectId('5e65c110d162fe0e0bcd1aa6')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥29.80', 'deal': '5.5万+', 'title': '卫龙大礼包辣条亲嘴烧豆干麻辣味整箱儿时小吃休闲美食网红零食品', 'shop': '猫诚旗舰店', 'location': '安徽 合肥', '_id': ObjectId('5e65c110d162fe0e0bcd1aa7')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥69.90', 'deal': '1064', 'title': '满299减200丨肖三婆无骨鸭掌150g麻辣去脱骨鸭爪四川特产卤味美食', 'shop': '肖三婆旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65c110d162fe0e0bcd1aa8')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥45.90', 'deal': '1869', 'title': '阿宽白家红油面皮12袋1260g特色小吃方便面非火鸡面成都特色美食', 'shop': '天猫超市', 'location': '上海', '_id': ObjectId('5e65c110d162fe0e0bcd1aa9')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥64.90', 'deal': '1120', 'title': '盼盼肉松饼整箱营养早餐糕点小吃面包特产美食网红小零食2100g', 'shop': '盼盼食品官方旗舰店', 'location': '河南 漯河', '_id': ObjectId('5e65c110d162fe0e0bcd1aaa')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥189.00', 'deal': '1103', 'title': '散装【卫龙旗舰店】魔芋爽整箱辣条毛肚素食香麻辣网红美食小袋装', 'shop': '卫龙食品旗舰店', 'location': '河南 漯河', '_id': ObjectId('5e65c110d162fe0e0bcd1aab')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥123.00', 'deal': '2619', 'title': '【德州扒鸡旗舰店】德州扒鸡正宗鸡爪熟食零食美食德州 扒鸡600g3', 'shop': '德州扒鸡旗舰店', 'location': '山东 德州', '_id': ObjectId('5e65c110d162fe0e0bcd1aac')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥92.90', 'deal': '1796', 'title': '廖记棒棒鸡无骨鸡爪两份920g 四川特色小吃麻辣无骨鸡爪零食美食', 'shop': '廖记棒棒鸡旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65c110d162fe0e0bcd1aad')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥68.00', 'deal': '230', 'title': '沈大成糕点桂花拉糕2盒 上海特产老字号 糯米糕点心 网红美食', 'shop': '沈大成旗舰店', 'location': '上海', '_id': ObjectId('5e65c110d162fe0e0bcd1aae')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥39.90', 'deal': '5500+', 'title': '嘉华鲜花饼云腿小饼12枚礼袋云南特产零食小吃美食早餐传统糕点心', 'shop': '嘉华食品旗舰店', 'location': '云南 昆明', '_id': ObjectId('5e65c110d162fe0e0bcd1aaf')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥19.90', 'deal': '3.5万+', 'title': '【良品铺子-甜辣鸭脖子190g】卤味零食小吃美食休闲食品小包装', 'shop': '良品铺子旗舰店', 'location': '广东 广州', '_id': ObjectId('5e65c110d162fe0e0bcd1ab0')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥56.00', 'deal': '2859', 'title': '桂花鸭南京盐水鸭1000g正宗江苏特产年货美食板鸭咸水鸭真空熟食', 'shop': '桂花鸭旗舰店', 'location': '江苏 南京', '_id': ObjectId('5e65c110d162fe0e0bcd1ab1')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥69.90', 'deal': '1963', 'title': '双鱼猪肉脯400克靖江特产猪肉铺金奖猪肉干自然片老字号中华美食', 'shop': '双鱼食品旗舰店', 'location': '江苏 泰州', '_id': ObjectId('5e65c110d162fe0e0bcd1ab2')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥84.90', 'deal': '2087', 'title': '桃李天然酵母面包1800g营养早餐零食美食品手撕口袋面包蛋糕整箱', 'shop': '桃李食品旗舰店', 'location': '辽宁 沈阳', '_id': ObjectId('5e65c110d162fe0e0bcd1ab3')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥69.00', 'deal': '1567', 'title': '杨大爷五花腊肉500g四川美食特产腊肉农家自制烟熏肥咸肉柴火腊肉', 'shop': '杨大爷旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65c110d162fe0e0bcd1ab4')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥20.50', 'deal': '3567', 'title': '满减【三只松鼠_墨玉川式芝麻酥135g】美食早餐小吃点心休闲零食', 'shop': '三只松鼠旗舰店', 'location': '安徽 芜湖', '_id': ObjectId('5e65c110d162fe0e0bcd1ab5')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥29.90', 'deal': '4786', 'title': '来伊份虎皮蛋糕168gx2糕点零食奶香夹心蛋糕美食早餐软点心小包装', 'shop': '来伊份官方旗舰店', 'location': '上海', '_id': ObjectId('5e65c110d162fe0e0bcd1ab6')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥109.00', 'deal': '729', 'title': '桂花鸭南京盐水鸭+酱鸭2000g特产正宗美食送礼真空装熟食年货食品', 'shop': '桂花鸭旗舰店', 'location': '江苏 南京', '_id': ObjectId('5e65c110d162fe0e0bcd1ab7')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥178.00', 'deal': '510', 'title': '修文鸭舌温州特产酱鸭舌酱卤鸭舌头原味美食小吃休闲零食净重480g', 'shop': '修文食品官方旗舰店', 'location': '浙江 温州', '_id': ObjectId('5e65c110d162fe0e0bcd1ab8')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥29.90', 'deal': '3.0万+', 'title': '绝艺鸭货零食大礼包麻辣味网红小吃休闲食品充饥夜宵整箱散装美食', 'shop': '绝艺食品旗舰店', 'location': '湖南 长沙', '_id': ObjectId('5e65c110d162fe0e0bcd1ab9')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥121.00', 'deal': '1150', 'title': '【旗舰店】螺状元柳州螺蛳粉280g*10袋礼盒装特产美食广西螺丝粉', 'shop': '螺状元旗舰店', 'location': '广西 柳州', '_id': ObjectId('5e65c110d162fe0e0bcd1aba')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥36.90', 'deal': '1.0万+', 'title': '沈师傅鸡蛋干四川特产豆腐干成都美食豆干小吃零食休闲食品非150g', 'shop': '沈师傅旗舰店', 'location': '四川 成都', '_id': ObjectId('5e65c110d162fe0e0bcd1abb')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥29.90', 'deal': '1.0万+', 'title': '五芳斋绿豆糕伴手礼桂花糕办公室点心休闲小吃零食绿豆饼好吃美食', 'shop': '五芳斋官方旗舰店', 'location': '浙江 嘉兴', '_id': ObjectId('5e65c110d162fe0e0bcd1abc')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥90.00', 'deal': '679', 'title': '美珍香芝士烧烤猪肉200g女生办公室零食网红特产小吃小孩肉类美食', 'shop': '美珍香旗舰店', 'location': '上海', '_id': ObjectId('5e65c110d162fe0e0bcd1abd')} 存储到MongoDB成功 {'image': '//g.alicdn.com/s.gif', 'price': '¥60.00', 'deal': '1620', 'title': '奇多粟米棒休闲食品小吃零食整箱混装90*12童年回忆怀旧网红美食', 'shop': '百事集团官方旗舰店', 'location': '江苏 无锡', '_id': ObjectId('5e65c110d162fe0e0bcd1abe')}参考文章：https://cuiqingcai.com/5657.html
结果如下：程序运行结果"C:\Program Files\Python\Python38\python.exe" E:/PycharmProjects/test/爬虫/今日头条街拍/Spider.py 请求文章详情页出错 None 正在下载1d47b4dceb635bff92ef296ce530cdc2.jpg 正在下载bff2d27b1d4ed77cc0a575513b9eeea4.jpg 正在下载f30c57b85c75fe655612450c993b320b.jpg 正在下载2475f2ad97bdcb6a45e6d64ce1650ca6.jpg 正在下载52fc1cd305b52366532f3ec7a9729a71.jpg 正在下载dc59cae9ed2859454c461b2944b819b1.jpg 正在下载bf1b48c4ca5cfeffec3bee95b1da6b64.jpg 正在下载7b8c8a28c037eac669988e34e90e37de.jpg 正在下载ad0fb9dbfcc0f15981fd701339e13bb8.jpg 正在下载98486366369a8c0b79f4c6ced3fb51b0.jpg E:/PycharmProjects/test/爬虫/今日头条街拍/Spider.py:125: DeprecationWarning: insert is deprecated. Use insert_one or insert_many instead. if db[MONGO_TABLE].insert(result): 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6760980286252515853/', 'title': '三里屯街拍', 'images': ['http://p9.pstatp.com/origin/pgc-image/f23cd60127824cb88b11256cf9ffe951', 'http://p9.pstatp.com/origin/pgc-image/0c54ffb46fdd4553ad99e9273a85643f', 'http://p9.pstatp.com/origin/pgc-image/da0dd5a6d8314f699de340c06a9093ec', 'http://p3.pstatp.com/origin/pgc-image/7fff7dff1863466883d0920481bc9ffe', 'http://p1.pstatp.com/origin/pgc-image/9ddcb34586514ab7ad6427c73c416f51', 'http://p3.pstatp.com/origin/pgc-image/a406850542ca496aa1f68333e42aea87', 'http://p1.pstatp.com/origin/pgc-image/50bb8781363e4e3e8e9e45137ded07f6', 'http://p3.pstatp.com/origin/pgc-image/6dfc140a4d814cd49295f210aa1499bd', 'http://p1.pstatp.com/origin/pgc-image/014679ab63584e0ca7f8612b8b120651', 'http://p9.pstatp.com/origin/pgc-image/be0226872a864d2aac76c28987938cdf'], '_id': ObjectId('5e648f564d5a25526d8630e9')} 请求文章详情页出错 None 正在下载289d58776687584857ea8d2cec8e3266.jpg 正在下载4d89bd5efc7166322207e31e737cd6d2.jpg 正在下载bcfd11725613120a2f6f20145521bf70.jpg 正在下载2256eed522bab696d578be7bd021a79d.jpg 正在下载9f4b6fac29acae9d0d3964a33922cd76.jpg 正在下载6226b26aacb6111fa5bb6ab4ecb360ca.jpg 正在下载22e469ecf6277bf6631e9053b0782656.jpg 正在下载fb6e9bba0afd3880fd5acb418c08af06.jpg 正在下载9e418d8f5aa93beefe64005a941b0b8d.jpg 正在下载dc98a060a3ee9abe1583bc304de1dfd1.jpg 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6797731729667785220/', 'title': '10张街拍，都是移动的美景', 'images': ['http://p1.pstatp.com/origin/pgc-image/e783e840dfb54e3c8c30c385d1089345', 'http://p9.pstatp.com/origin/pgc-image/9476cd0974cb4a2984665b2c5b983212', 'http://p1.pstatp.com/origin/pgc-image/d4fbc13cfc2d43ac8161b4be08df3e14', 'http://p3.pstatp.com/origin/pgc-image/b18028cec93146a2b51e5671da0521d5', 'http://p1.pstatp.com/origin/pgc-image/64bd25e7787e4273a2286b35a3ae6446', 'http://p3.pstatp.com/origin/pgc-image/dfa087e2320241b3a17911d4e0ac3029', 'http://p3.pstatp.com/origin/pgc-image/3d8f1af2896147ee93bf2d2fd7ba9ca8', 'http://p1.pstatp.com/origin/pgc-image/120a3479c1e64c339fd248804e65e07a', 'http://p9.pstatp.com/origin/pgc-image/c4719a980d674138bcdf6f275ef02641', 'http://p3.pstatp.com/origin/pgc-image/9166a9f1c804471289a2561b132e6c2d'], '_id': ObjectId('5e648f584d5a25526d8630ea')} 请求文章详情页出错 None 正在下载058f885bfde3719ed25338005a437383.jpg 正在下载232333b9f0f2b87a553e8f24f728890e.jpg 正在下载b81adeef46b7948a2ae60ba19b1c2f9f.jpg 正在下载0617b7ed0ad9230354903c6afe97db35.jpg 正在下载a9a568400013d371b26f9ed5ed475867.jpg 正在下载3fe54e96b51b9ace46634e8f94ab5592.jpg 正在下载33110348606726d108c04b7c40b964d9.jpg 正在下载a1052b801e72efdbfc1c4cc0a81aac95.jpg 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6798525975911989767/', 'title': '8张街拍，美腿是亮点', 'images': ['http://p1.pstatp.com/origin/pgc-image/016ab17507bd46639a130da594e0c5a7', 'http://p1.pstatp.com/origin/pgc-image/a812e94ff2634cd88e3212d0f8e2e69d', 'http://p3.pstatp.com/origin/pgc-image/2e71f3fe533e4907be31731dfa27d42b', 'http://p3.pstatp.com/origin/pgc-image/e57e58cf58204fa0849b6b10f27c2a63', 'http://p1.pstatp.com/origin/pgc-image/2430de0431354ccb98683a2e48886679', 'http://p1.pstatp.com/origin/pgc-image/9c122e7a3c764c249c5c1f8a89d2d92d', 'http://p1.pstatp.com/origin/pgc-image/d812aa22e3b94c5382afaf6c23970dcd', 'http://p3.pstatp.com/origin/pgc-image/015a672717b24791ba75ad876238c79b'], '_id': ObjectId('5e648f5a4d5a25526d8630eb')} 请求文章详情页出错 None 正在下载2f03708f2837f73dcb109d23f9416792.jpg 正在下载bd905f5aa9bbf02485958efdbbac1dd9.jpg 正在下载d217942affa862060bc9196e38d7c79c.jpg 正在下载81bfdb8072c2345216b26df2eacad4de.jpg 正在下载49187040d908d5ecaaa66fc1d4065594.jpg 正在下载63afad5c014c8b814f3f2985e1f6f0e9.jpg 正在下载32b7ad87244b35dfb0537aa17db4d481.jpg 正在下载788e4bc0f4656154c3155e4c8fb8c86b.jpg 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6544662303671845383/', 'title': '街拍美女，每个都不会让你失望，能拍到这么多很难得', 'images': ['http://p1.pstatp.com/origin/pgc-image/1523797525926884c65306e', 'http://p3.pstatp.com/origin/pgc-image/152379752620949b0806b6a', 'http://p3.pstatp.com/origin/pgc-image/1523797526532845db7eb8f', 'http://p9.pstatp.com/origin/pgc-image/1523797526872017fabff50', 'http://p1.pstatp.com/origin/pgc-image/15237975272443a6dc806be', 'http://p1.pstatp.com/origin/pgc-image/1523797527522d8e7dd116e', 'http://p1.pstatp.com/origin/pgc-image/15237975277918d0c1769d3', 'http://p9.pstatp.com/origin/pgc-image/152379753708045ae2bcea6'], '_id': ObjectId('5e648f5d4d5a25526d8630ec')} 请求文章详情页出错 None 正在下载1c24d58fcecb7c040d7eecb7f5f40812.jpg 正在下载57a39dd807a981d1cbc0ce114084bc5a.jpg 正在下载539b075ff4afec5baa3277758a7b6c4d.jpg 正在下载928ec49ea00572be1dc16bcbe970f0f7.jpg 正在下载7851da03c9b9d535a9c271a12db6d3d7.jpg 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6801700984973165059/', 'title': '街拍时尚美女达人，个性时尚靓丽', 'images': ['http://p1.pstatp.com/origin/pgc-image/f5c5829387b14ff99685a28a0eeab0fe', 'http://p3.pstatp.com/origin/pgc-image/fdec9a612a6044feb92f981be07821ba', 'http://p3.pstatp.com/origin/pgc-image/4e1028d6ff804bdb8286087699c93dd6', 'http://p3.pstatp.com/origin/pgc-image/ec39dfbd5e6f4d1e8ddbf093c5dac423', 'http://p3.pstatp.com/origin/pgc-image/21be061a0fbf47d5a9084d707757a0e0'], '_id': ObjectId('5e648f614d5a25526d8630ed')} 请求文章详情页出错 None 正在下载60451c6c4904eb992260fe3337a7da85.jpg 正在下载4e8b28d7767d035ebb2e9be015af5f12.jpg 正在下载40f67d5373b2eb26f502002cc8d1379f.jpg 正在下载317532fa5039e4707a55f095f5287ea4.jpg 正在下载4f849724eadfb58e743d95ed35e01ca1.jpg 正在下载51a4b4e42cd90441c988d5747a1fa0ce.jpg 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6793512652669714956/', 'title': '路人街拍，随性有度，高颜值任性', 'images': ['http://p1.pstatp.com/origin/pgc-image/812c6785511940859d0ae8340023cd33', 'http://p1.pstatp.com/origin/pgc-image/a95721f9184c467195c1f03ebf5ddb2d', 'http://p1.pstatp.com/origin/pgc-image/87a94ae849e64590a691f5866a75a6a6', 'http://p1.pstatp.com/origin/pgc-image/2463ca69bd38421eb2b3fcb87a2b6485', 'http://p3.pstatp.com/origin/pgc-image/437bf5b276ef4d178c33f3b5121aacad', 'http://p3.pstatp.com/origin/pgc-image/3729b42f46a741cd85366d08fa10dabe'], '_id': ObjectId('5e648f644d5a25526d8630ee')} 请求文章详情页出错 None 正在下载605a6964f274bf05359a94611d766c90.jpg 正在下载b263ab68d9f2a481282f0b95dd8185da.jpg 正在下载22229fb6e545aa1c362a864a254dc190.jpg 正在下载7178df50a0dc98dd8081462c55b39abb.jpg 正在下载c47eeecb2060eb7e979b26d201c89d85.jpg 正在下载8196e60f431fc88c07faf569b0d410d5.jpg 正在下载7b60211a6c1e85cd8d0a5b313a3eea54.jpg 正在下载a9e01aa5e7bf45092479ce5b545e5b43.jpg 正在下载704ab8f5cf3ed7fe6684c29fc85c32b9.jpg 正在下载ff47896bf7d103e1f11c92291a6e22fa.jpg 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6798491818288742915/', 'title': '街拍：时尚的美女们那无处安放的魅力呀', 'images': ['http://p3.pstatp.com/origin/pgc-image/6ad69aabdd7b4638a4d1ae95ad03aa31', 'http://p3.pstatp.com/origin/pgc-image/d687b4a681d04c96966ca068571cbfc7', 'http://p1.pstatp.com/origin/pgc-image/5d1800490a45422a8ecf640aec508117', 'http://p3.pstatp.com/origin/pgc-image/0fbd7554e6e44b0baffeddba5e682397', 'http://p3.pstatp.com/origin/pgc-image/be0f015c0ef4494f891948cb9b2079df', 'http://p1.pstatp.com/origin/pgc-image/7f2443587bfe47a584e2fc03d6274b44', 'http://p9.pstatp.com/origin/pgc-image/7bad2342572f4141a72c963c3bf7489d', 'http://p9.pstatp.com/origin/pgc-image/546965a83e344dfe8939142381401839', 'http://p3.pstatp.com/origin/pgc-image/7f351bd5863146e384849ca68e858f89', 'http://p1.pstatp.com/origin/pgc-image/b087dddab5874b049eb97b5cc0e5a46e'], '_id': ObjectId('5e648f6b4d5a25526d8630ef')} 正在下载c0d75e4999e69d869e86d5fec1f59485.jpg 正在下载56ba253418c432c99a57331cf38c34d0.jpg 正在下载3d17fffb0618658810d3e03f4051a8ae.jpg 正在下载a0406a502caf02ff77cf96dd173c0a58.jpg 正在下载62d84cedab105e433c88afb0327780c6.jpg 正在下载ae8e01add6e9d85ec8aff9d495a68985.jpg 正在下载62be7702c19941666ab7550add3b0846.jpg 正在下载c40e65a1ee585414a10fd62c2f1abc3c.jpg 正在下载400900353f90b9f0c1dccbc41254bf6e.jpg 正在下载c55892d7a5d3bff48d2ec49698b8cc77.jpg 正在下载2bfb96396e6ac8c655994505d2787813.jpg 正在下载4f29434ac280b66c11c97d9cbee304a0.jpg 正在下载1a0a748c67847be27d477f4dc5629ce2.jpg 正在下载bbf03b4c64ee88e8f30f7ce9c4ffb75d.jpg 正在下载aa06350b58919b0bf4c8dcf67dfa051d.jpg 正在下载e8204bc0995bb67209f1ae2ce46dfa6d.jpg 正在下载5ae505e545b1a0ddae53f4d9e04af17e.jpg 正在下载3170b09e65c287c47d9424a569c8b211.jpg 正在下载93729e56d76c91baf217e668853b9675.jpg 正在下载d32daacb8c3c6760d171b25d257e620f.jpg 正在下载0b85fb287c9a9a0e1ed178ec3ce6c7ad.jpg 正在下载6632d9ceccb7f048060f6121d3471028.jpg 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6360561337588465922/', 'title': '三里屯时尚街拍', 'images': ['http://p1.pstatp.com/origin/127a000565b624674d7f', 'http://p9.pstatp.com/origin/11f60008aea95af99269', 'http://p3.pstatp.com/origin/127b0000b91a74ee8aa0', 'http://p9.pstatp.com/origin/127b0000b91d0af5e30d', 'http://p9.pstatp.com/origin/11ff00035036c49b99ff', 'http://p1.pstatp.com/origin/127a000565c33e48688d', 'http://p3.pstatp.com/origin/127a000565c5bb7a220d', 'http://p1.pstatp.com/origin/127b0000bb5db97385a5', 'http://p3.pstatp.com/origin/127b0000bb839a6d7fdd', 'http://p3.pstatp.com/origin/11ff0003528897cbd6a3', 'http://p1.pstatp.com/origin/127b0000bbca727e9712', 'http://p1.pstatp.com/origin/11ff000352d0b620b45d', 'http://p3.pstatp.com/origin/127b0000bc09a4933d91', 'http://p3.pstatp.com/origin/127a000568ba70678b41', 'http://p3.pstatp.com/origin/11ff0003530c352041b2', 'http://p1.pstatp.com/origin/1279000000228a83fb2d', 'http://p1.pstatp.com/origin/11f80002e84fb20134ff', 'http://p1.pstatp.com/origin/127900000061ba8db7f1', 'http://p1.pstatp.com/origin/127d0000008129c92602', 'http://p9.pstatp.com/origin/127d000000c6b41742c7', 'http://p1.pstatp.com/origin/1279000000cfe9cf96a5', 'http://p3.pstatp.com/origin/127d000000e8996bb8a1'], '_id': ObjectId('5e648f714d5a25526d8630f0')} 正在下载e8b059259110fb7b2145238c783e1e16.jpg 正在下载4e611f9b0bf4f50be7da523398b81ccb.jpg 正在下载f114136a7df71b5e303903ed8bdfde16.jpg 正在下载08189490c08f7072cc3d7df8e2e3a9ca.jpg 正在下载73812fb5ba1d4f781cd86cccac76e7b1.jpg 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6801620851247546887/', 'title': '街拍：身材好，朴素的搭配也好看', 'images': ['http://p3.pstatp.com/origin/pgc-image/229b29b9d46d41b59a6b1241b4f6522e', 'http://p3.pstatp.com/origin/pgc-image/22a06b2a0b9c452b91b8b8fe5ff9eeb9', 'http://p9.pstatp.com/origin/pgc-image/6545bf27a1d84b7695fe75913165dc3f', 'http://p1.pstatp.com/origin/pgc-image/68e79f9722524c2b9e95e369231e881f', 'http://p3.pstatp.com/origin/pgc-image/4add570ae30949319ee7a82a8a70905e'], '_id': ObjectId('5e648f744d5a25526d8630f1')} 正在下载6ad8e277bc909ab8b2aef5f65e6fc108.jpg 正在下载68dec26885c44b8d592b16799fab9bec.jpg 正在下载ca0d1280000bd094ee618107525c50cd.jpg 正在下载9f3eb9fb5e1587ba4ea6563b41bba065.jpg 正在下载b803cfbd980e1ea37c9943cecbe4d9d2.jpg 正在下载52beaad3de4da77a21d6b33b9c6bc535.jpg 正在下载818ec69ece423d6ef53df0e673755db3.jpg 正在下载4582c657f330e7925dad64d9a43ee23b.jpg 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6801713871884124686/', 'title': '图虫街拍摄影：无题', 'images': ['http://p3.pstatp.com/origin/tuchong.fullscreen/243059128_tt', 'http://p1.pstatp.com/origin/tuchong.fullscreen/192138312_tt', 'http://p3.pstatp.com/origin/tuchong.fullscreen/311282017_tt', 'http://p1.pstatp.com/origin/tuchong.fullscreen/238865179_tt', 'http://p3.pstatp.com/origin/tuchong.fullscreen/229820783_tt', 'http://p3.pstatp.com/origin/tuchong.fullscreen/503761196_tt', 'http://p3.pstatp.com/origin/tuchong.fullscreen/63687246_tt', 'http://p1.pstatp.com/origin/tuchong.fullscreen/292407501_tt'], '_id': ObjectId('5e648f784d5a25526d8630f2')} 请求文章详情页出错 None 正在下载a83165d608142d3673f161ddcbe78473.jpg 正在下载2a3a99a77ecac2a5d5053b76984af14a.jpg 正在下载e13ff6d472651823cf060564621858c3.jpg 正在下载60715dabb78cb7f25bd4c7e773816b98.jpg 正在下载fd5a68dea6558fab2dbcd4ee33a66bb5.jpg 正在下载bea2d6122c2b4b9cac123b870fa2a2e5.jpg 正在下载1433ff923ee966d7aad93306a00e9194.jpg 正在下载3515669e22dc198da7413bd1bc144b26.jpg 正在下载2b0a30397d74c8307b2fe208c101cb6b.jpg 正在下载ea938a964c692a72889c3550946beb40.jpg 正在下载27acc644e75f99ed74c3d2fe7ac90c90.jpg 正在下载6e4d52ef6cd03cf1b08e1aa2f66049af.jpg 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6761387978905354765/', 'title': '街拍美女', 'images': ['http://p3.pstatp.com/origin/pgc-image/75cedc8655974a5393d37001cc997ffb', 'http://p1.pstatp.com/origin/pgc-image/7867bd5c02c040519de20b4f7b6aec86', 'http://p1.pstatp.com/origin/pgc-image/85bb485b37ab4ae893333b2a3a1d3bdc', 'http://p3.pstatp.com/origin/pgc-image/25e8b5d6b07542e891d8589272dc43f0', 'http://p1.pstatp.com/origin/pgc-image/d241f49affaf43f1b8ccb26e5de6dfd9', 'http://p3.pstatp.com/origin/pgc-image/d86a1ed0b6a84e0b9df9e9132346751f', 'http://p3.pstatp.com/origin/pgc-image/78aa27e880eb415f9b08fcace47dbbad', 'http://p1.pstatp.com/origin/pgc-image/1752f41b2b86499d8986986783cb2986', 'http://p1.pstatp.com/origin/pgc-image/e55546f4cd29475da01997ded3d7c0d1', 'http://p1.pstatp.com/origin/pgc-image/25d0fc56b79a437086b70d57ee2d2d57', 'http://p9.pstatp.com/origin/pgc-image/d5c878a943ed46fb87e1c059831a1127', 'http://p3.pstatp.com/origin/pgc-image/0340686e0c7a417f8262fb8a9a0b6854'], '_id': ObjectId('5e648f7e4d5a25526d8630f3')} 正在下载69e442ab916aacb3381271b40536d918.jpg 正在下载db907cb5a1036864aff213d46984a88d.jpg 正在下载04b93d83f943a0507ed547b6736f535a.jpg 正在下载c5ead73b64e742f5f81fe29cb1f86fdf.jpg 正在下载21ed741bc8196cc52dc2e3881e3ea2b7.jpg 正在下载ced7135b971626d5830f01eee8e70813.jpg 正在下载7cc78999ee6e6ec05380d976884df636.jpg 存储到MongoDB成功 {'url': 'http://toutiao.com/group/6801669716575257099/', 'title': '街拍格子衬衫+黑色束腰大衣，美女绽放迷人微笑', 'images': ['http://p9.pstatp.com/origin/pgc-image/08ab6c2fafb84551b6b9018a070bdfc3', 'http://p1.pstatp.com/origin/pgc-image/7878dfe8070a4922b2f41996745e3257', 'http://p3.pstatp.com/origin/pgc-image/a8402a23183d4cb7a67af9bf8e387c94', 'http://p3.pstatp.com/origin/pgc-image/d962686c0d3848abb28bf5f1c42dcfdd', 'http://p1.pstatp.com/origin/pgc-image/3b97d9f5b9bf4676968a89a7f01299f1', 'http://p3.pstatp.com/origin/pgc-image/91ec603752794b5b8d9d0c67e68eeb5d', 'http://p9.pstatp.com/origin/pgc-image/b401c7c025a04c17a4e99484330e32fb'], '_id': ObjectId('5e648f844d5a25526d8630f4')} 请求文章详情页出错 None 进程已结束，退出代码 0 代码贴上：import json import os from _md5 import md5 from urllib.parse import urlencode from bs4 import BeautifulSoup from requests.exceptions import RequestException import requests import re import pymongo MONGO_URL = 'localhost' MONGO_DB = 'toutiao_jiepai' MONGO_TABLE = 'jiepai' client = pymongo.MongoClient(MONGO_URL, connect=False) db = client[MONGO_DB] GROUP_STARST = 0 GROUP_END = 20 KEYWORD = '街拍' headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36', 'cookie': 'csrftoken=bf9266cc133025b21a5e4998ffd5ce35; tt_webid=6790686063313733134; UM_distinctid=1701fb35e91866-04c171aadb2013-b791b36-144000-1701fb35e9279a; ttcid=86d38a88812b421583147156ab016ec237; _ga=GA1.2.1866509185.1582287463; s_v_web_id=verify_k794o57o_YRKnMOhd_FUeV_4ZdI_Bpo2_3vXzw7x5Gx3a; __utma=24953151.1866509185.1582287463.1583116936.1583116936.1; __utmz=24953151.1583116936.1.1.utmcsr=mp.toutiao.com|utmccn=(referral)|utmcmd=referral|utmcct=/profile_v3/weitoutiao; __utmc=24953151; SLARDAR_WEB_ID=7b78defd-3070-4596-9123-59244140755e; passport_auth_status=0f792b07d1cc7e289d22eff873cc7c10%2C05d5a1d4bfea33adb46666e2ce9e3596; toutiao_sso_user=7da7c4fb85bcf55cc492a893a21d6251; sessionid=a915499f555249bdb4f3589e50930ec3; uid_tt=769f44a859173e5be80260a51aff7903; sid_tt=a915499f555249bdb4f3589e50930ec3; tt_scid=hu9kP-IprXVAhkiPwrxxRBJJFpnHByB.40Boc8LMWZxP.rmAnLe5H8ltCAKUsLk4032b; __tasessionId=tchl9rncq1583588525235; CNZZDATA1272960458=515500770-1581078898-%7C1583585464' } # 获得通过ajax请求返回的json数据 def get_page_index(offset, keyword): data = { 'aid': '24', 'app_name': 'web_search', 'offset': offset, 'format': 'json', 'keyword': keyword, 'autoload': 'true', 'count': '20', 'en_qc': '1', 'cur_tab': '1', 'from': 'search_tab', 'pd': 'synthesis', 'timestamp': '1583588896243' } url = 'https://www.toutiao.com/api/search/content/?' + urlencode(data) # https://www.toutiao.com/api/search/content/?aid=24&app_name=web_search # &offset=0&format=json&keyword=%E8%A1%97%E6%8B%8D&autoload=true&count=20 # &en_qc=1&cur_tab=1&from=search_tab&pd=synthesis&timestamp=1583588896243 try: response = requests.get(url, headers=headers) if response.status_code == 200: return response.text return None except RequestException: print("请求ajax出错") return None # 获得每篇文章的url def parse_page_index(html): data = json.loads(html) if data and 'data' in data.keys(): for item in data.get('data'): yield item.get('article_url') # 返回article_url # 获得文章详情页的源代码 def get_page_detail(url): try: response = requests.get(url, headers=headers) if response.status_code == 200: return response.text return None except RequestException: print("请求文章详情页出错", url) return None def parse_page_detail(html, url): soup = BeautifulSoup(html, 'lxml') images_pattern = re.compile('BASE_DATA.galleryInfo.*?gallery: JSON.parse\("(.*?)"\),', re.S) result = re.search(images_pattern, html) if result: title = soup.select('title')[0].get_text() # print(title) # print(result.group(1)) data = result.group(1).encode('utf-8').decode('unicode-escape') # 去掉\\\u002F，先用utf-8编码再用unicode-escape解码 data = json.loads(data) # 转换成json格式的字符串 if data and 'sub_images' in data.keys(): sub_images = data.get('sub_images') images = [item.get('url') for item in sub_images] for image in images: download_image(image, title) return { 'url': url, 'title': title, 'images': images } def download_image(url, title): try: response = requests.get(url, headers=headers) if response.status_code == 200: save_image(response.content, title) return None except RequestException: print("请求图片出错", url) return None def save_image(content, title): dir_name = title if not os.path.exists(dir_name): os.makedirs(dir_name) file_path = '{0}.{1}'.format(md5(content).hexdigest(), 'jpg') print('正在下载' + file_path) if not os.path.exists(file_path): with open(dir_name + '/' + file_path, 'wb') as f: f.write(content) f.close() def save_to_mongo(result): if db[MONGO_TABLE].insert(result): print("存储到MongoDB成功", result) return True return False def main(offset): html = get_page_index(offset, KEYWORD) # print(html) for url in parse_page_index(html): # print(url) html = get_page_detail(url) if html: result = parse_page_detail(html, url) # print(result) if result: save_to_mongo(result) if __name__ == '__main__': for offset in range(GROUP_STARST, GROUP_END + 1, 20): main(offset) 参考链接：https://www.cnblogs.com/YangARTuan/p/10591503.html
Python用正则爬取豆瓣读书之新书速递的书籍信息
新书速递的书籍信息数据的主要采集出处 夏先生的故事 [德] 帕特里克·聚斯金德 夏先生的故事 [德] 帕特里克·聚斯金德 / 2020-1 / 上海译文出版社 《香水》作者聚斯金德回归纯真之作。 《纽约客》御用画手、法国国宝级插画大师桑贝经典配图。 “我”是一个普通的小男孩，上学，爬树，骑车，幻想着朦胧的初恋，害怕严厉的钢琴教师，常常觉得自己会飞。“我”的邻居夏先生是个“怪人”，沉默地拄着拐杖，背着空空的行囊，没有目的地奔走不休。我们之间只有为数不多的几次接触，但这个敏感易怒、行色匆匆、似乎总在忍受... 代码如下import requests import re url = "https://book.douban.com/" headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36'} content = requests.get(url, headers=headers).text # 使用re.S参数以后，正则表达式会将这个字符串作为一个整体，将“\n”当做一个普通的字符加入到这个字符串中，在整体中进行匹配。 pattern = re.compile( '<li.*?cover.*?href="(.*?)\stitle="(.*?)">.*?src="(.*?)".*?more-meta.*?author">(.*?).*?year">(.*?).*?publisher">(.*?).*? ', re.S) ##这里应该要在URL和title之间匹配空格，用\s results = re.findall(pattern, content) for result in results: url, name, img_url, author, date, publisher = result author = re.sub('\s', '', author) # 把前后的空白符去掉 author=author.strip()也可以 date = re.sub('\s', '', date) publisher = re.sub('\s', '', publisher) print(name, author, date, publisher, url, img_url) 结果数据如下人类向何处去 [英]奥拉夫·斯特普尔顿 2020-1 北京航空航天大学出版社 https://book.douban.com/subject/34934004/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33549854.jpg 戏剧游戏：儿童戏剧游戏 [英]凯瑟琳·扎切斯特 / KatherineZachest 2020-1 后浪丨上海文化出版社 https://book.douban.com/subject/34935067/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33550710.jpg 算计 [日]米泽穗信 2020-1 人民文学出版社 https://book.douban.com/subject/34866078/?icn=index-latestbook-subject" https://img1.doubanio.com/view/subject/s/public/s33542087.jpg 从催眠的世界中不断醒来 姜涛 2020-1 华东师范大学出版社 https://book.douban.com/subject/34951625/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33562486.jpg 十三封自杀告别信 [德]科斯汀•吉尔 2020-1-1 新星出版社 https://book.douban.com/subject/34908017/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33531850.jpg 论爱与死亡 [德]帕·聚斯金德 2020-1 上海译文出版社 https://book.douban.com/subject/34863425/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33545431.jpg 俗世奇人全本 冯骥才 2020-1 人民文学出版社 https://book.douban.com/subject/34924477/?icn=index-latestbook-subject" https://img1.doubanio.com/view/subject/s/public/s33571357.jpg 中国史学史稿 刘节 2020-2 商务印书馆 https://book.douban.com/subject/26997226/?icn=index-latestbook-subject" https://img1.doubanio.com/view/subject/s/public/s33552418.jpg 秋风平地起 [法]让·雅克·桑贝 2020-1 上海译文出版社 https://book.douban.com/subject/34845973/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33555024.jpg 当权的第三帝国 [英]理查德·J.埃文斯 2020-2 九州出版社 https://book.douban.com/subject/34925415/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33578800.jpg 尚待商榷的爱情 (英)朱利安·巴恩斯 2020-2-10 文汇出版社 https://book.douban.com/subject/34893656/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33560231.jpg 禅与饮茶的艺术 [美]威廉·斯科特·威尔逊（WilliamScottWilson） 2020-1 湖南人民出版社 https://book.douban.com/subject/34923176/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33549261.jpg 见鬼 有鬼君 2020-3 东方出版社 https://book.douban.com/subject/34879052/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33555840.jpg 罪恶之城的骑士：雷蒙德·钱德勒传 [英]汤姆·威廉斯 2020-3 南京大学出版社 https://book.douban.com/subject/20396757/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33544366.jpg 年轻的心在哭泣 [美]理查德·耶茨 2020-2 上海译文出版社 https://book.douban.com/subject/34888770/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33561625.jpg 历史人类学的旨趣 赵世瑜 2020-1 北京师范大学出版社 https://book.douban.com/subject/34933514/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33576650.jpg 埃郡往事 [加]杰夫·勒米尔 2020-1-10 天津人民出版社 https://book.douban.com/subject/34869654/?icn=index-latestbook-subject" https://img1.doubanio.com/view/subject/s/public/s33541918.jpg 声音集 [阿根廷]安东尼奥·波尔基亚 2020-1 人民文学出版社 https://book.douban.com/subject/34431899/?icn=index-latestbook-subject" https://img1.doubanio.com/view/subject/s/public/s33556179.jpg 神圣家族 梁鸿 2020-4 中信出版集团 https://book.douban.com/subject/34970714/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33576724.jpg 护士的故事 [英]克里斯蒂·沃森 2020-4 浦睿文化·湖南人民出版社 https://book.douban.com/subject/34922193/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33576240.jpg 鸽子 [德]帕·聚斯金德 2020-1 上海译文出版社 https://book.douban.com/subject/34863427/?icn=index-latestbook-subject" https://img1.doubanio.com/view/subject/s/public/s33545417.jpg 工具，还是武器？ 【美】布拉德·史密斯 / 【美】卡罗尔·安·布朗 2020-2 中信出版集团 https://book.douban.com/subject/34940580/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33583216.jpg 恺撒 [澳]考琳·麦卡洛 2020-2-1 文化发展出版社有限公司 https://book.douban.com/subject/34867159/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33585401.jpg 美国海：墨西哥湾的历史 [美]杰克·E.戴维斯 2020-2 索·恩| 社会科学文献出版社 https://book.douban.com/subject/34889903/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33549255.jpg 人间游戏：伤痕 钟宇 2020-3-1 中国友谊出版公司 https://book.douban.com/subject/34947381/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33560860.jpg 巴黎记 于坚 2020-2-1 江苏凤凰文艺出版社/楚尘文化 https://book.douban.com/subject/34948397/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33560144.jpg 钢琴的重量 [美]克丽丝·坎德 2020-1-13 北京联合出版公司 https://book.douban.com/subject/34710239/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33555656.jpg 花鸟风月日本史 高桥千剑破 2020-3 未读·文艺家 贵州人民出版社 https://book.douban.com/subject/34939912/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33581672.jpg 新宋·9－12（大结局珍藏版） 阿越 2020-2 河北人民出版社 https://book.douban.com/subject/34919443/?icn=index-latestbook-subject" https://img1.doubanio.com/view/subject/s/public/s33540197.jpg 莱奥纳多·达·芬奇：绘画论 [法]安德烈·夏斯泰尔编译 2020-2 理想国 | 湖南美术出版社 https://book.douban.com/subject/34937633/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33560166.jpg 十一种孤独 [美]理查德·耶茨 2020-2 上海译文出版社 https://book.douban.com/subject/34888719/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33561560.jpg 奥斯曼帝国 林佳世子 2020-1 北京日报出版社 https://book.douban.com/subject/34869429/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33582600.jpg 羔羊的盛宴 [日]米泽穗信 2020-1 人民文学出版社 https://book.douban.com/subject/34431939/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33542083.jpg 与神作战 [英]蒂姆·惠特马什 2020-2 社会科学文献出版社 https://book.douban.com/subject/34842532/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33576262.jpg 夏先生的故事 [德]帕特里克·聚斯金德 2020-1 上海译文出版社 https://book.douban.com/subject/34863428/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33545404.jpg 杀人执照 [德]埃格蒙特·科赫 2020-3 生活·读书·新知三联书店 https://book.douban.com/subject/34802968/?icn=index-latestbook-subject" https://img9.doubanio.com/view/subject/s/public/s33564334.jpg 低音提琴 [德]帕·聚斯金德 2020-1 上海译文出版社 https://book.douban.com/subject/34863426/?icn=index-latestbook-subject" https://img1.doubanio.com/view/subject/s/public/s33545437.jpg 维正之供 周健 2020-1-1 北京师范大学出版社 https://book.douban.com/subject/34869893/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33507700.jpg 战春秋 海飞 2020-2 北京十月文艺出版社 https://book.douban.com/subject/34943410/?icn=index-latestbook-subject" https://img1.doubanio.com/view/subject/s/public/s33561098.jpg 戳中痛点，成为文案高手 [日]中野巧 2020-4 低音 • 北京联合出版公司 https://book.douban.com/subject/34431990/?icn=index-latestbook-subject" https://img3.doubanio.com/view/subject/s/public/s33555322.jpg
爬取豆瓣读书Top100的书籍信息（实则只有79本书）import requests import json from lxml import etree import re import time class Spider: def __init__(self): self.url_temp = 'https://www.douban.com/doulist/118410371/?start={}' self.headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36'} # 1.根据地址的规律构造url_list def get_url_list(self): url_list = [self.url_temp.format(i) for i in range(0, 76, 25)] return url_list # 2.发送请求，获取响应 def req_url_resp(self, url): print('start:' + url) response = requests.get(url, headers=self.headers) return response.content.decode() # 3.提取数据 def get_content_list(self, resp_content): content = etree.HTML(resp_content) content_list = [] # 用列表存储信息 div_list = content.xpath("//div[@class='article']//div[@class='doulist-item']") for div in div_list: item = {} item['title'] = div.xpath(".//div[@class='title']/a/text()")[0].strip() item['author'] = div.xpath(".//div[@class='abstract']/text()")[0].strip() # 作者：江一帆 try: result = re.search(".*:(.*)", item['author']) item['author'] = result.group(1) # 江一帆 except Exception as e: print(e) item['press'] = div.xpath(".//div[@class='abstract']/text()")[1].strip() if len( div.xpath(".//div[@class='abstract']/text()")) > 1 else None # 出版社: 你叫啥出版社 try: result = re.search(".*:(.*)", item['press']) item['press'] = result.group(1) # 你叫啥出版社 except Exception as e: print(e) item['time'] = div.xpath(".//div[@class='abstract']/text()")[2].strip() if len( div.xpath(".//div[@class='abstract']/text()")) > 2 else None # 出版年: 2020-3-2 try: result = re.search(".*:(.*)", item['time']) item['time'] = result.group(1) # 2020-3-2 except Exception as e: print(e) item['rating_nums'] = div.xpath(".//div[@class='rating']/span/text()")[0] # 评分 item['rating_people_nums'] = div.xpath(".//div[@class='rating']/span/text()")[1].strip('(').strip(')') # 评分人数 item['img'] = div.xpath(".//div[@class='post']/a/img/@src") content_list.append(item) return content_list # 4.保存数据 def save_content(self, content_list): with open("Top100.txt", 'a', encoding='utf-8') as f: for content in content_list: f.write(json.dumps(content, ensure_ascii=False)) f.write('\n') print('保存成功！') def run(self): # 1.根据地址的规律构造url_list url_list = self.get_url_list() # 2.发送请求，获取响应 for url in url_list: time.sleep(1) resp_content = self.req_url_resp(url) # 3.提取数据 content_list = self.get_content_list(resp_content) # 4.保存数据 self.save_content(content_list) if __name__ == '__main__': spider = Spider() spider.run() Top100.txt信息如下{"title": "海底两万里", "author": " [法国] 儒尔·凡尔纳", "press": " 译林出版社", "time": " 2002-9", "rating_nums": "8.5", "rating_people_nums": "72656人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s1817666.jpg"]} {"title": "红与黑", "author": " [法] 司汤达", "press": " 人民文学出版社", "time": " 2002", "rating_nums": "8.2", "rating_people_nums": "45558人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s2332189.jpg"]} {"title": "茶花女", "author": " 小仲马", "press": " 外国文学出版社", "time": " 1997-3", "rating_nums": "8.2", "rating_people_nums": "103636人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s1008927.jpg"]} {"title": "羊脂球", "author": " （法）莫泊桑", "press": " 北京燕山出版社", "time": " 2007-6", "rating_nums": "8.2", "rating_people_nums": "84444人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s1469280.jpg"]} {"title": "呼啸山庄", "author": " （英）勃朗特 / 张玲 / 张扬", "press": " 人民文学出版社", "time": " 1999-01-01", "rating_nums": "8.4", "rating_people_nums": "97965人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s1095383.jpg"]} {"title": "巴黎圣母院", "author": " [法]雨果", "press": " 人民文学出版社", "time": " 1982-6", "rating_nums": "8.4", "rating_people_nums": "87972人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s4493741.jpg"]} {"title": "简爱（英文全本）", "author": " [英] 夏洛蒂·勃朗特", "press": " 世界图书出版公司", "time": " 2003-11", "rating_nums": "8.5", "rating_people_nums": "179148人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s5924326.jpg"]} {"title": "鲁滨逊漂流记", "author": " [英] 笛福", "press": " 广西民族出版社", "time": " 2002-1", "rating_nums": "8.1", "rating_people_nums": "148648人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s1242786.jpg"]} {"title": "飘", "author": " 米切尔", "press": " 人民文学出版社", "time": " 1990-8", "rating_nums": "9.6", "rating_people_nums": "810人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s7626051.jpg"]} {"title": "基督山伯爵（上下）", "author": " 大仲马", "press": " 中国对外翻译出版公司", "time": " 1999", "rating_nums": "9.5", "rating_people_nums": "149人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s2792916.jpg"]} {"title": "丝路朝圣", "author": " 王邦维", "press": " 中华书局", "time": " 2019-1", "rating_nums": "8.1", "rating_people_nums": "13人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s29973040.jpg"]} {"title": "消失的地平线", "author": " 2012-7", "press": null, "time": null, "rating_nums": "8.4", "rating_people_nums": "14人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s24224473.jpg"]} {"title": "黑客与画家", "author": " [美] Paul Graham", "press": " 人民邮电出版社", "time": " 2011-4", "rating_nums": "8.7", "rating_people_nums": "17677人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s4669554.jpg"]} {"title": "爱的艺术", "author": " [美] 艾·弗洛姆", "press": " 上海译文出版社", "time": " 2008-4", "rating_nums": "8.8", "rating_people_nums": "26413人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s2990934.jpg"]} {"title": "白鹿原", "author": " 陈忠实", "press": " 人民文学出版社", "time": " 1997-12", "rating_nums": "8.9", "rating_people_nums": "16199人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s26012567.jpg"]} {"title": "万水千山走遍", "author": " 三毛", "press": " 哈尔滨出版社", "time": " 2003-08", "rating_nums": "8.8", "rating_people_nums": "31279人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s1099483.jpg"]} {"title": "万物有灵且美", "author": " [英] 吉米·哈利", "press": " 中国城市出版社", "time": " 2010-1", "rating_nums": "8.8", "rating_people_nums": "17454人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s4093514.jpg"]} {"title": "不能承受的生命之轻", "author": " 米兰·昆德拉", "press": " 上海译文出版社", "time": " 2010-8", "rating_nums": "8.8", "rating_people_nums": "25180人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s4421443.jpg"]} {"title": "时间简史", "author": " [英] 史蒂芬·霍金", "press": " 湖南科学技术出版社", "time": " 2010-4", "rating_nums": "8.8", "rating_people_nums": "43078人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s1914861.jpg"]} {"title": "孩子你慢慢来", "author": " 龙应台", "press": " 生活·读书·新知三联书店", "time": " 2009-12-1", "rating_nums": "8.8", "rating_people_nums": "56927人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s4124434.jpg"]} {"title": "一只特立独行的猪", "author": " 王小波", "press": " 北方文艺出版社", "time": " 2006-4", "rating_nums": "8.8", "rating_people_nums": "64477人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s1670642.jpg"]} {"title": "梦里花落知多少", "author": " 三毛", "press": " 北京十月文艺出版社", "time": " 2007-6", "rating_nums": "8.8", "rating_people_nums": "69308人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s2393243.jpg"]} {"title": "看不见的城市", "author": " [意大利]伊塔洛·卡尔维诺", "press": " 译林出版社", "time": " 2006-8", "rating_nums": "8.8", "rating_people_nums": "32753人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s1804710.jpg"]} {"title": "爱你就像爱生命", "author": " 王小波 / 李银河", "press": " 上海锦绣文章出版社", "time": " 2008-5", "rating_nums": "8.8", "rating_people_nums": "77147人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s4661043.jpg"]} {"title": "呐喊", "author": " 鲁迅", "press": " 人民文学出版社", "time": " 1973年3月", "rating_nums": "8.9", "rating_people_nums": "80494人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s4696893.jpg"]} {"title": "黄金时代", "author": " 王小波", "press": " 陕西师范大学出版社", "time": " 2009-07-01", "rating_nums": "8.9", "rating_people_nums": "37923人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s4083149.jpg"]} {"title": "追风筝的人", "author": " [美] 卡勒德·胡赛尼", "press": " 上海人民出版社", "time": " 2006-5", "rating_nums": "8.9", "rating_people_nums": "605302人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s1727290.jpg"]} {"title": "看见", "author": " 柴静", "press": " 广西师范大学出版社", "time": " 2013-1-1", "rating_nums": "8.8", "rating_people_nums": "257745人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s24468373.jpg"]} {"title": "全球通史（第7版 上册）", "author": " [美] 斯塔夫里阿诺斯", "press": " 北京大学出版社", "time": " 2005-1", "rating_nums": "8.9", "rating_people_nums": "12633人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s9985895.jpg"]} {"title": "野火集", "author": " 龙应台", "press": " 生活·读书·新知三联书店", "time": " 2010-1-5", "rating_nums": "8.9", "rating_people_nums": "13140人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s4390060.jpg"]} {"title": "浮生六记", "author": " （清）沈复", "press": " 人民文学出版社", "time": " 1999-1", "rating_nums": "8.8", "rating_people_nums": "37415人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s2280094.jpg"]} {"title": "激荡三十年（下）", "author": " 吴晓波", "press": " 中信出版社 浙江人民出版社", "time": " 2008-1", "rating_nums": "8.9", "rating_people_nums": "16922人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s2879952.jpg"]} {"title": "城南旧事", "author": " 林海音 文 / 关维兴 图", "press": " 中国青年出版社", "time": " 2003-7", "rating_nums": "9.0", "rating_people_nums": "85519人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s2654869.jpg"]} {"title": "悲惨世界（上中下）", "author": " [法] 雨果", "press": " 人民文学出版社", "time": " 1992-6", "rating_nums": "9.0", "rating_people_nums": "45430人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s4521754.jpg"]} {"title": "格林童话全集", "author": " [德国]格林兄弟", "press": " 人民文学出版社", "time": " 1994-11", "rating_nums": "9.0", "rating_people_nums": "62162人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s1134341.jpg"]} {"title": "哭泣的骆驼", "author": " 三毛", "press": " 哈尔滨出版社", "time": " 2003-6", "rating_nums": "8.9", "rating_people_nums": "41795人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s1020454.jpg"]} {"title": "无人生还", "author": " [英] 阿加莎・克里斯蒂", "press": " 人民文学出版社", "time": " 2008-3", "rating_nums": "8.9", "rating_people_nums": "89070人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s2962510.jpg"]} {"title": "基督山伯爵", "author": " 大仲马", "press": " 上海译文出版社", "time": " 1991-12-1", "rating_nums": "9.0", "rating_people_nums": "92682人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s3248016.jpg"]} {"title": "人生的枷锁", "author": " [英] 毛姆", "press": " 上海译文出版社", "time": " 2007-3", "rating_nums": "9.0", "rating_people_nums": "17857人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s3983958.jpg"]} {"title": "万历十五年", "author": " [美] 黄仁宇", "press": " 中华书局", "time": " 2006-8", "rating_nums": "9.0", "rating_people_nums": "18690人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s1790028.jpg"]} {"title": "圣经", "author": " 三一神", "press": " 中国基督教协会", "time": " 1996", "rating_nums": "9.0", "rating_people_nums": "14773人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s1677577.jpg"]} {"title": "人间词话", "author": " 王国维", "press": " 上海古籍出版社", "time": " 1998-12-01", "rating_nums": "9.0", "rating_people_nums": "35600人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s9130587.jpg"]} {"title": "我与地坛", "author": " 史铁生", "press": " 春风文艺出版社", "time": " 2002-5", "rating_nums": "9.0", "rating_people_nums": "50767人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s1151479.jpg"]} {"title": "局外人", "author": " [法] 阿尔贝·加缪", "press": " 上海译文出版社", "time": " 2010-8", "rating_nums": "9.0", "rating_people_nums": "110507人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s4468484.jpg"]} {"title": "我的精神家园", "author": " 王小波", "press": " 文化艺术出版社", "time": " 1997", "rating_nums": "9.1", "rating_people_nums": "27933人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s1016763.jpg"]} {"title": "江城", "author": " [美] 彼得·海斯勒", "press": " 上海译文出版社", "time": " 2012-1", "rating_nums": "9.0", "rating_people_nums": "33998人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s32271204.jpg"]} {"title": "星空", "author": " 幾米", "press": " 大塊文化", "time": " 2009-5-1", "rating_nums": "9.0", "rating_people_nums": "18909人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s4150073.jpg"]} {"title": "刀锋", "author": " [英]毛姆", "press": " 上海译文出版社", "time": " 2007-3", "rating_nums": "9.0", "rating_people_nums": "49893人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s2347562.jpg"]} {"title": "傲慢与偏见", "author": " [英] 奥斯丁", "press": " 上海译文出版社", "time": " 1996-12", "rating_nums": "9.0", "rating_people_nums": "31112人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s27017338.jpg"]} {"title": "历史深处的忧虑", "author": " 林达", "press": " 生活·读书·新知三联书店", "time": " 1997-5", "rating_nums": "9.0", "rating_people_nums": "34661人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s1768916.jpg"]} {"title": "寻路中国", "author": " [美] 彼得·海斯勒", "press": " 上海译文出版社", "time": " 2011-1", "rating_nums": "9.0", "rating_people_nums": "39087人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s4575849.jpg"]} {"title": "嫌疑人X的献身", "author": " [日] 东野圭吾", "press": " 南海出版公司", "time": " 2009-11", "rating_nums": "9.0", "rating_people_nums": "45252人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s4055190.jpg"]} {"title": "沉默的大多数", "author": " 王小波", "press": " 中国青年出版社", "time": " 1997-10", "rating_nums": "9.1", "rating_people_nums": "89702人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s1447349.jpg"]} {"title": "霍乱时期的爱情", "author": " [哥伦比亚] 加西亚·马尔克斯", "press": " 南海出版公司", "time": " 2012-9-1", "rating_nums": "9.0", "rating_people_nums": "163194人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s11284102.jpg"]} {"title": "夹边沟记事", "author": " 杨显惠", "press": " 花城出版社", "time": " 2008-09", "rating_nums": "9.2", "rating_people_nums": "24308人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s3455551.jpg"]} {"title": "王尔德童话", "author": " [英] 王尔德", "press": " 译林出版社", "time": " 2003-6", "rating_nums": "9.1", "rating_people_nums": "13903人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s2019056.jpg"]} {"title": "围城", "author": " 钱锺书", "press": " 人民文学出版社", "time": " 2007-8", "rating_nums": "9.2", "rating_people_nums": "23753人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s6941453.jpg"]} {"title": "中国历代政治得失", "author": " 钱穆", "press": " 生活·读书·新知三联书店", "time": " 2001", "rating_nums": "9.2", "rating_people_nums": "38380人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s1319205.jpg"]} {"title": "父与子全集", "author": " [德] 埃·奥·卜劳恩 绘", "press": " 中国工人出版社", "time": " 2003-4", "rating_nums": "9.2", "rating_people_nums": "36853人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s1094608.jpg"]} {"title": "安徒生童话故事集", "author": " （丹麦）安徒生", "press": " 人民文学出版社", "time": " 1997-08", "rating_nums": "9.2", "rating_people_nums": "76618人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s1034062.jpg"]} {"title": "小王子", "author": " （法）圣埃克苏佩里", "press": " 中国友谊出版公司", "time": " 2000-9", "rating_nums": "9.2", "rating_people_nums": "12246人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s3294754.jpg"]} {"title": "上帝掷骰子吗", "author": " 曹天元", "press": " 辽宁教育出版社", "time": " 2006-1", "rating_nums": "9.2", "rating_people_nums": "19456人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s1486674.jpg"]} {"title": "平凡的世界（全三册）", "author": " 路遥", "press": " 北京十月文艺出版社", "time": " 2009-1", "rating_nums": "9.1", "rating_people_nums": "31690人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s3799757.jpg"]} {"title": "文学回忆录（全2册）", "author": " 木心 讲述 / 陈丹青 笔录", "press": " 广西师范大学出版社", "time": " 2013-1-10", "rating_nums": "9.2", "rating_people_nums": "31053人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s24611679.jpg"]} {"title": "明朝那些事儿", "author": " 当年明月", "press": " 浙江人民出版社", "time": " 2011-12-1", "rating_nums": "9.2", "rating_people_nums": "20724人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s29399938.jpg"]} {"title": "滚蛋吧!肿瘤君", "author": " 熊顿", "press": " 北京理工大学出版社", "time": " 2012-9-1", "rating_nums": "9.2", "rating_people_nums": "14987人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s20742806.jpg"]} {"title": "月亮和六便士", "author": " [英] 毛姆", "press": " 上海译文出版社", "time": " 2009-10", "rating_nums": "9.1", "rating_people_nums": "36349人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s6088624.jpg"]} {"title": "白夜行", "author": " [日] 东野圭吾", "press": " 南海出版公司", "time": " 2013-1-1", "rating_nums": "9.2", "rating_people_nums": "212649人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s24514468.jpg"]} {"title": "三国演义（全二册）", "author": " [明] 罗贯中", "press": " 人民文学出版社", "time": " 1998-05", "rating_nums": "9.2", "rating_people_nums": "109506人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s1076932.jpg"]} {"title": "三体Ⅱ", "author": " 刘慈欣", "press": " 重庆出版社", "time": " 2008-5", "rating_nums": "9.3", "rating_people_nums": "213130人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s3078482.jpg"]} {"title": "百年孤独", "author": " [哥伦比亚] 加西亚·马尔克斯", "press": " 南海出版公司", "time": " 2011-6", "rating_nums": "9.2", "rating_people_nums": "264725人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s6384944.jpg"]} {"title": "人类简史", "author": " [以色列] 尤瓦尔·赫拉利", "press": " 中信出版社", "time": " 2014-11", "rating_nums": "9.1", "rating_people_nums": "116769人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s27814883.jpg"]} {"title": "动物庄园", "author": " 乔治•奥威尔 (George Orwell)", "press": " 上海三联书店", "time": " 2009-6-1", "rating_nums": "9.3", "rating_people_nums": "25314人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s3858411.jpg"]} {"title": "撒哈拉的故事", "author": " 三毛", "press": " 北京十月文艺出版社", "time": " 2011-1-7", "rating_nums": "9.3", "rating_people_nums": "47975人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s6780941.jpg"]} {"title": "活着", "author": " 余华", "press": " 作家出版社", "time": " 2012-8-1", "rating_nums": "9.4", "rating_people_nums": "417869人评价", "img": ["https://img3.doubanio.com/view/subject/l/public/s29053580.jpg"]} {"title": "飘", "author": " [美国] 玛格丽特·米切尔", "press": " 译林出版社", "time": " 2000-9", "rating_nums": "9.3", "rating_people_nums": "142867人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s1078958.jpg"]} {"title": "1984", "author": " [英] 乔治·奥威尔", "press": " 万卷出版公司", "time": " 2010-10", "rating_nums": "9.4", "rating_people_nums": "20130人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s4542846.jpg"]} {"title": "红楼梦", "author": " [清] 曹雪芹 著 / 高鹗 续", "press": " 人民文学出版社", "time": " 1996-12", "rating_nums": "9.6", "rating_people_nums": "257636人评价", "img": ["https://img1.doubanio.com/view/subject/l/public/s1070959.jpg"]} {"title": "史记（全十册）", "author": " 司马迁 / 张守节", "press": " 中华书局", "time": " 1982-11", "rating_nums": "9.5", "rating_people_nums": "15049人评价", "img": ["https://img9.doubanio.com/view/subject/l/public/s1953384.jpg"]}
这只是一个测试一级标题二级标题三级标题四级标题加粗文字斜体文字有序列表有序列表列表项目列表项目列表项目列表项目列表项目无序列表列表项目列表项目列表项目列表项目列表项目引用文字private String userName; private int userPassword; public User(){ }/* **123 **dgdgsggdfgdsg */ //sgdgsdgsdg public class User { private String userName; private int userPassword; public User(){ } public User(String userName, int userPassword) { this.userName = userName; this.userPassword = userPassword; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public void setUserPassword(int userPassworduserPassworduserPassworduserPassworduserPassworduserPassword) { this.userPassword = userPassworduserPassworduserPassworduserPassworduserPassworduserPassword; } public int getUserPassword() { return userPassword; } }#include<iostream> using namespace std; int main(){ int x; float y; cout<<"Please input an int number:"<<endl; cin>>x; cout<<"The int number is x= "<<x<<endl; cout<<"Please input a float number:"<<endl; cin>>y; cout<<"The float number is y= "<<y<<endl; return 0; }#include<iostream> using namespace std; int main(){ int x; float y; cout<<"Please input an int number:"<<endl; cin>>x; cout<<"The int number is x= "<<x<<endl; cout<<"Please input a float number:"<<endl; cin>>y; cout<<"The float number is y= "<<y<<endl; return 0; }count = 0 while (count < 9): print 'The count is:', count count = count + 1 print "Good bye!"分割线摘要分割线