Data Analysis/web crawling
[Crawling] 데이터 보내는 방법
아이스베어 :)
2021. 6. 7. 17:15
728x90
반응형
* 본 포스팅은 주피터 노트북에서 진행되었다.
url = "https://hello-ming.tistory.com/"
res=rq.get(url,params={"key":"홍길동","key1":"홍말자","key2":"김개똥"})
res.url #한글은 꺠진다.
res=rq.get(url,params={"key":"hong","key1":"malga","key2":"hi"})
res.url
url = "https://hello-ming.tistory.com//?key=hong&key1=malga"
res.url #위와 같은방식인데 이거는 오타날 확률이 있음
Post로 데이터 보내기
url = "https://hello-ming.tistory.com/"
res=rq.post(url, data={"key1":"hong","key2":"icebear"})
res.url #post로 body에 싣어 보냄
dict1 = {"key1":"hong","key2":"icebear"}
import json
json.dumps(dict1) # '{"key1": "hong", "key2": "icebear"}'
str(dict1) # '{"key1": "hong", "key2": "icebear"}'
둘다 문자열 형태로 감 json 형태 유지의 차이
from urllib.request import urlopen,Request
req = Request(url)
page = urlopen(req)
page
728x90
반응형