Deadly simple non official dcinside api for python3

eunchuldev, updated πŸ•₯ 2023-03-12 14:22:46

dcinside-python3-api

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()) ```

Dependency

python(>3.6) aiohttp, lxml

Features

  • [x] Board crawling
  • [x] Fetch document body
  • [x] Fetch comments
  • [x] Fetch document images
  • [x] Write/Modify/Delete document
  • [x] Write comment
  • [ ] Delete comment
  • [ ] Login/Logout
  • [ ] Upvote/Downvote

Usage

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")

```

Issues

λΉ„μΆ”κ°€ μ—†λŠ” 가러리 λ¬Έμ„œλ₯Ό 읽을 μ‹œ μ—λŸ¬λ°œμƒ μˆ˜μ •

opened on 2023-03-12 14:22:45 by kohcy128 None

[λΉ„μΆ”]κ°€ μ—†λŠ” 가러리 λ¬Έμ„œλ₯Ό 읽을 μ‹œ μ—λŸ¬ λ°œμƒ.

opened on 2023-02-11 19:57:15 by dr-nitro-lab

[λΉ„μΆ”]λ₯Ό 막아놓은 가러리λ₯Ό λŒ€λΉ„ν•΄ λ”°λ‘œ μ˜ˆμ™Έ μ²˜λ¦¬κ°€ ν•„μš”ν• λ“― . . μ–Έμ œ ν•΄κ²°ν•˜μ‹€μ§„ λͺ¨λ₯΄κ² μ§€λ§Œ 일단 기둝으둜 λ‚¨κ²¨λ‘‘λ‹ˆλ‹€.

Fixed to parse a past year correctly

opened on 2023-01-11 04:53:27 by somneer
  • A datetime already has a right year, so there is no need to imbue current year

μ•ˆλ…•ν•˜μ„Έμš” κΆκΈˆν•œμ μ΄ μžˆμŠ΅λ‹ˆλ‹€.

opened on 2022-12-08 08:29:57 by hangari123

write_document의 contents 뢀뢄에 html νƒœκ·ΈλŠ” λ„£μ„μˆ˜ μ—†λŠ”κ±΄κ°€μš”? 링크λ₯Ό λ„£μ—ˆλ”λ‹ˆ λ””μ‹œμ—μ„œ ν•„ν„°λ§λ˜μ„œ λ‚˜μ˜€λ”λΌκ³ μš”.. 예λ₯Όλ“€λ©΄ 링크 μ΄λŸ°μ‹μœΌλ‘œ ν•˜λ©΄ μ£Όμ†Œλ§Œ λ‚˜μ˜€λ”λΌκ³ μš”.. μ œκ°€ μ›ν•˜λŠ”κ±΄ λ§ν¬λΌλŠ” κΈ€μžμ— μ£Όμ†Œκ°€ μž…ν˜€μ§„ ν˜•νƒœλ‘œ μž‘μ„±λ˜κΈΈ μ›ν•˜κ±°λ“ μš”.. ν˜Ήμ‹œ 방법 μ—†λ‚˜μš”?

Fix bug for referencing Document.comment_count

opened on 2022-11-05 08:45:58 by anon-kaitou None

μ•ˆλ…•ν•˜μ„Έμš”, api.board()μ—μ„œ λ‚ μ§œ μˆ˜μ§‘μ— λ¬Έμ œκ°€ 있고, 또 api.document() λ©”μ†Œλ“œκ°€ μž‘λ™ν•˜μ§€ μ•ŠλŠ” 것 κ°™μŠ΅λ‹ˆλ‹€.

opened on 2022-09-15 17:32:56 by minvv23

μ•ˆλ…•ν•˜μ„Έμš”, μ‚¬μš© 쀑에 두 κ°€μ§€ 문제λ₯Ό λ°œκ²¬ν•΄μ„œ λ‚¨κΉλ‹ˆλ‹€.

1. api.board()μ—μ„œ λ‚ μ§œλ₯Ό μ „λΆ€ ν˜„μž¬ λ…„λ„μ˜ 23:59:59둜 μ½μ–΄μ˜΅λ‹ˆλ‹€. κ·Έλž˜μ„œ μœ€λ…„μΈ 2020λ…„ 2μ›” 29일 κ²Œμ‹œλ¬Όμ„ μ½μ–΄μ˜¬ λ•ŒλŠ” ValueError: day is out of range for month μ—λŸ¬κ°€ λ°œμƒν•©λ‹ˆλ‹€.

2. api.document() λ©”μ†Œλ“œ μžμ²΄κ°€ μž‘λ™μ„ ν•˜μ§€ μ•ŠλŠ” 것 κ°™μŠ΅λ‹ˆλ‹€. document λ©”μ†Œλ“œκ°€ κ·Έλƒ₯ None을 λ°˜ν™˜ν•©λ‹ˆλ‹€.