ajax
$.ajax({
type: "GET",
url: "url",
data: {},
success: function(response){
console.log(response)
}
})
bs4
import requests
from bs4 import BeautifulSoup
headers = {'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36'}
data = requests.get('url',headers=headers)
soup = BeautifulSoup(data.text, 'html.parser')
Tag1 = soup.select('body > div') #body 내의 모든 div를 찾아줌
Tag2 = soup.select_one('body > .one') #body 내의 .one클래스를 가진 제일 윗 태그를 찾아줌.
Tag3 = Tag2.text #태그 내의 텍스트 부분만 가져와줌
pymongo
from pymongo import MongoClient
client = MongoClient('localhost', 27017)
db = client.DBname
doc = {'name':'bobby','age':21}
db.users.insert_one(doc) #mongoDB에 document 를 넣어줌
all_users = list(db.users.find({})) #DB의 document를 뽑아줌
some_users = list(db.users.find({'age':21},{'_id':False})) #DB의 특정값을 가진 document들을 뽑아줌. 불필요한 _id 값은 안보이도록 False 처리.
one_user = db.users.find_one({'name':'bobby'}) #특정값을 가진 document 맨 위 하나만 뽑아줌.
db.users.update_many({'name':'bobby'},{'$set':{'age':19}}) #특정값을 가진 document 모두 변경. 모든 바비의 나이를 19살로 변경
db.users.update_one({'name':'bobby'},{'$set':{'age':19}}) #한 바비의 나이를 19살로 변경.
db.users.delete_one({'name':'bobby'}) #특정값을 가진 document 제거.
'이것저것 코딩공부' 카테고리의 다른 글
AJAX, ajax, fetch, axios 의 관계성.. (0) | 2021.09.21 |
---|---|
[JS] 서버 올렸더니 자바스크립트로 구현한 복사 기능 에러 이유 (0) | 2021.09.18 |
맥/윈도우에서 AWS EC2 터미널로 접속하기 (0) | 2021.09.13 |
내가 써본 파이썬 라이브러리/패키지 대충 설명 (0) | 2021.09.13 |
[VScode] 왕초보가 java 사용할때 생기는 오류 해결법 저장소 (0) | 2021.08.20 |