Skip to content

Instantly share code, notes, and snippets.

@tiger1710
Created November 21, 2020 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiger1710/96a9f9d459362eeffd6b0640fada1f3b to your computer and use it in GitHub Desktop.
Save tiger1710/96a9f9d459362eeffd6b0640fada1f3b to your computer and use it in GitHub Desktop.
from urllib.parse import quote_plus, urlencode
import requests
from urllib.request import urlopen, Request
session = requests.Session
url = 'http://apis.data.go.kr/1160100/service/GetStocDiviInfoService/getDiviInfo'
queryParams = '?' + urlencode({
quote_plus('ServiceKey') : 'gJzlDCS7IS9dZXyGkrtszUr0x5BophBoSedp7A6TEATYpeG9rzLVB8sOyNKf8kRUWl7cc50has2ogGw9KWGICw%3D%3D',
quote_plus('pageNo') : '1',
quote_plus('numOfRows') : '10',
quote_plus('resultType') : 'xml',
quote_plus('basDt') : '',
quote_plus('crno') : '1101110057012',
quote_plus('stckIssuCmpyNm') : '동남합성'
})
req = Request(url + queryParams)
req.get_method = lambda: 'GET'
response_body = urlopen(req).read().decode('utf-8')
print(response_body)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment