我正在尝试连接并选择mongodb集合中的每个对象。这就是我所做的。
#!/bin/shmongo 104.198.195.35:27017/yelp --eval"db.getCollection('yelp').find({})"
for i in $( mongo104.198.195.35:27017/yelp --eval "db.getCollection('yelp').find({})" ); do
echo item: $i
done
我是shell脚本中的菜鸟。
以下是上述脚本的结果示例。
item: "website_url"
item: :
item: "-"
item: }
item: ]
item: }
item: ],
item: "search_string"
item: :
item: "Best
item: gyms
item: ,
item: near
item: Los
item: Angeles,
item: CA
item: 90091,"
item: }
item: Type
item: "it"
item: for
item: more
我的脚本将此作为字符串而不是拾取对象
我想接这个
{
"_id" : ObjectId("576826eb1a4f5d7fabf2dfe4"),
"search_url" : "http://www.yelp.com/search?find_desc=Gyms&find_loc=Los+Angeles%2C+CA&ns=1",
"search_url_id" : 1,
"search_group" : "YelpTest",
"Results" : [
{
"search_page_no" : 1,
"page_results" : [
{
"rating" : "5.0",
"name" : "BossFitnessLA",
"tags" : "Trainers",
"url" : "http://www.yelp.com/biz/bossfitnessla-beverly-hills",
"rank" : "991",
"contact_telephone" : "(310) 595-8811",
"address" : "Beverly Hills, 415N Beverly Dr, Beverly Hills, CA 90210",
"no_of_reviews" : "9",
"website_url" : "-"
},
{
"rating" : "5.0",
"name" : "TK Fitness LA",
"tags" : "Trainers",
"url" : "http://www.yelp.com/biz/tk-fitness-la-west-hollywood",
"rank" : "992",
"contact_telephone" : "(323) 428-1445",
"address" : "Hollywood, 828 N La Brea Ave, West Hollywood, CA 90038",
"no_of_reviews" : "7",
"website_url" : "-"
},
{
"rating" : "2.5",
"name" : "LA Fitness",
"tags" : "Gyms, Trainers, Sports Clubs",
"url" : "http://www.yelp.com/biz/la-fitness-monterey-park",
"rank" : "993",
"contact_telephone" : "(323) 346-6061",
"address" : "416 South Atlantic Blvd Building B, Monterey Park, CA 91754",
"no_of_reviews" : "192",
"website_url" : "-"
},
{
"rating" : "4.0",
"name" : "Warner Bros Fitness Studio",
"tags" : "Gyms",
"url" : "http://www.yelp.com/biz/warner-bros-fitness-studio-burbank",
"rank" : "994",
"contact_telephone" : "(818) 954-4242",
"address" : "Burbank, 4000 Warner Blvd Bldg 25, Burbank, CA 91522",
"no_of_reviews" : "4",
"website_url" : "-"
}