dcinside-python3-api
Deadly simple non official async dcinside api for python3
# 프로그래밍 갤러리 글 무한 크롤링
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())
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
- Board crawling
- Fetch document body
- Fetch comments
- Fetch document images
- Write/Modify/Delete document
- 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
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")
Metadata
Release files for dc-api 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dc_api-0.8.0.tar.gz | 10.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dc_api-0.8.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / dc_api-0.8.0.tar.gz
| Download URL | dc_api-0.8.0.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eccf7ccc39a5e834803c3c3268738208d437b741ef01143e3557a8458af4f3c6
|
|
BLAKE2b-256 checksum How to use checksums |
70cb8080677dd84b58f1f76f5b766634f34bd08f7a47b014f51314abec7a09ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Release files / dc_api-0.8.0-py3-none-any.whl
| Download URL | dc_api-0.8.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81a95302bd88144584c8ee599c5e4c7431fdc3fdfb008c23c3f80d370bce8258
|
|
BLAKE2b-256 checksum How to use checksums |
bc5775b9a21946d765f72d0aeff454d7437cc37783eb384a6bc917eccbd2e6d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.6
|
Security for dc-api 0.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.