Deadly simple non official async dcinside api for python3
```python
import asyncio import dc_api
async def run(): async with dc_api.API() as api: async for index in api.board(board_id="programming"): print(index.title) # => λκ° λ²μ΄λλλ².tip doc = await index.document() print(doc.contents) # => μλ°λ₯Ό νλ€ for img in doc.images: img.download('./img') # => ./img.gif async for comm in index.comments(): print(com.contents) # => γ γ (1.224) μ§λ γ΄
asyncio.run(run()) ```
```python import asyncio import dc_api
async def run(): api = dc_api.API()
# λκΈ μμ± await api.write_comment(board_id="programming", doc_id=149123, name="γ γ ", password="1234", contents="γ γ ")
# κΈ μμ± doc_id = await api.write_document(board_id="programming", title="java vs python", contents="λ₯μΉκ³ μλ°", name="γ γ ", password="1234")
# κΈ μμ await api.remove_document(board_id="programming", doc_id=doc_id, password="1234")
# λ§μ΄λκ°€ κΈ μμ± doc_id = await api.write_document(board_id="aoegame", title="java vs python", contents="λ₯μΉκ³ μλ°", name="γ γ ", password="1234", is_minor=True)
await api.close()
asyncio.run(run()) ```
python(>3.6) aiohttp, lxml
Place dc_api.py in your working directory
or install via pip
pip3 install --user dc_api
```python import dc_api
api = dc_api.API()
async for index in api.board(board_id="programming", num=-1, start_page=1, document_id_upper_limit=None, document_id_lower_limit=None): index.id # => 835027 index.board_id # => programming index.title # => "λκ° λ²μ΄λλλ².tip" index.author # => "γ γ (10.20)" index.time # => datetime("2020-01-01 01:41:00.000000") index.comment_count # => 3 index.voteup_count # => 0 index.view_count # => 14
doc = await index.document()
doc.id # => 835027
doc.board_id # => "programming"
doc.title # => "λκ° λ²μ΄λλλ².tip"
doc.author # => "γ
γ
(10.20)"
doc.author_id # => None (κ³ λμΌ κ²½μ° κ³ λ μμ΄λ λ°ν)
doc.time # => datetime("2020-01-01 01:41:00.000000")
doc.comment_count # => 3
doc.voteup_count # => 0
doc.logined_voteup_count # => 0
doc.votedown_count # => 0
doc.view_count # => 14.id
doc.contents # => "μλ°λ₯Ό νλ€"
doc.html # => "<p> μλ°λ₯Ό νλ€ </p>"
for image in doc.images:
image.src # => "https://..."
image.document_id # => 835027
image.board_id # => "programming"
await image.load()# => raw image binary
await image.download(path) # => download image to local path(automatically add ext)
async for com in index.comments():
com.id # => 123123
com.is_reply # => False
com.time # => "1:55"
com.author # => "γ
γ
(192.23)"
com.author_id # => None (κ³ λμΌ κ²½μ° μμ΄λ λ°ν)
com.contents # => "κ°μ γ΄γ΄"
com.dccon # => None (λμμ½μΌκ²½μ° λμμ½ μ£Όμ λ°ν)
com.voice # => None (보μ΄μ€λ¦¬νμΌκ²½μ° 보μ΄μ€λ¦¬ν μ£Όμ λ°ν)
doc = await api.document(board_id="programming", document_id=835027)
async for comm in api.comments(board_id="programming", document_id=835027): comm
doc_id = await api.write_document(board_id="programming", name="μ μ§μ μμ΄", password="1234", title="μ λͺ©", contents="λ΄μ©", is_minor=False) doc_id = await api.modify_document(board_id="programming", document_id=document_id, name="μνκ³ ", pw="1234", title="μμ λ μ λͺ©", contents="μμ λ λ΄μ©", is_minor=False) com_id = await api.write_comment(board_id="programming", document_id=doc_id, name="μ μ§μ μμ΄", password="1234", contents="μ€λ¦¬") await api.remove_document(board_id="programming", document_id=document_id, password="1234")
```
[λΉμΆ]λ₯Ό λ§μλμ κ°€λ¬λ¦¬λ₯Ό λλΉν΄ λ°λ‘ μμΈ μ²λ¦¬κ° νμν λ― . . μΈμ ν΄κ²°νμ€μ§ λͺ¨λ₯΄κ² μ§λ§ μΌλ¨ κΈ°λ‘μΌλ‘ λ¨κ²¨λ‘λλ€.
write_documentμ contents λΆλΆμ html νκ·Έλ λ£μμ μλ건κ°μ? λ§ν¬λ₯Ό λ£μλλ λμμμ νν°λ§λμ λμ€λλΌκ³ μ.. μλ₯Όλ€λ©΄ λ§ν¬ μ΄λ°μμΌλ‘ νλ©΄ μ£Όμλ§ λμ€λλΌκ³ μ.. μ κ° μνλ건 λ§ν¬λΌλ κΈμμ μ£Όμκ° μ νμ§ ννλ‘ μμ±λκΈΈ μνκ±°λ μ.. νΉμ λ°©λ² μλμ?
μλ νμΈμ, μ¬μ© μ€μ λ κ°μ§ λ¬Έμ λ₯Ό λ°κ²¬ν΄μ λ¨κΉλλ€.
1. api.board()μμ λ μ§λ₯Ό μ λΆ νμ¬ λ λμ 23:59:59λ‘ μ½μ΄μ΅λλ€. κ·Έλμ μ€λ μΈ 2020λ 2μ 29μΌ κ²μλ¬Όμ μ½μ΄μ¬ λλ ValueError: day is out of range for month μλ¬κ° λ°μν©λλ€.
2. api.document() λ©μλ μμ²΄κ° μλμ νμ§ μλ κ² κ°μ΅λλ€. document λ©μλκ° κ·Έλ₯ Noneμ λ°νν©λλ€.