提交 fe9ac759 编写于 作者: C crj1998

add pictoa

上级 66a861d7
# meetslut # meetslut
> A fancy tools to download pictures from internt. > A fancy👠 tool to download pictures from internt.
## Installation ![010116-220-C](https://upload-images.jianshu.io/upload_images/13843118-f46b965a1c878a67.png)
## 🔨 Installation
``` ```
pip install beautifulsoup4 pip install beautifulsoup4
git clone git clone
...@@ -9,8 +11,7 @@ cd meetslut ...@@ -9,8 +11,7 @@ cd meetslut
pip install . pip install .
``` ```
Tutorial from [Converting Python Script Into a Command-line Tool](https://betterprogramming.pub/build-your-python-script-into-a-command-line-tool-f0817e7cebda) ## 💡 Usage
## Usage
``` ```
meetslut download --url https://www.python.org/static/img/python-logo.png -o path/to/python-logo.png meetslut download --url https://www.python.org/static/img/python-logo.png -o path/to/python-logo.png
``` ```
...@@ -24,12 +25,29 @@ python meetslut/cli.py caitlin 'https://caitlin.top/index.php?route=comic/readOn ...@@ -24,12 +25,29 @@ python meetslut/cli.py caitlin 'https://caitlin.top/index.php?route=comic/readOn
python meetslut/cli.py motherless https://motherless.com/GICB9A5D8?page=2 -o ~/work/saved python meetslut/cli.py motherless https://motherless.com/GICB9A5D8?page=2 -o ~/work/saved
``` ```
### Support ### 🚀 Support
> 📢 Update on 2022.11.05
✔️ success
❌ failed
❗️ proxy needed for mainland user
⭕️ developing
|Website|Status|Desc|
|---|---|---|
| [Caitlin](https://caitlin.top/)|✔️|comics|
| [zipai](https://99zipai.com/)|✔️|china amateur photos|
| [motherless]() |✔️|photo|
| [Imagefap]()|❌|photo|
| [pictoa](https://www.pictoa.com/)|⭕️|photo|
## 📑 License
- [Caitlin](https://caitlin.top/) ## 👋 Acknowledgement
- [zipai](https://99zipai.com/) - https://jinglong233.gitee.io/markdownIcon/
- [Imagefap]() - Tutorial from 📦 [Converting Python Script Into a Command-line Tool](https://betterprogramming.pub/build-your-python-script-into-a-command-line-tool-f0817e7cebda)
- [motherless]()
## License ## For Developers
\ No newline at end of file parser: input a url, output a dict {"url": ..., "name": ...}
\ No newline at end of file
""" """
The Command Line Interface (CLI) for the downloader The Command Line Interface (CLI) for the downloader
""" """
import os import os, argparse, logging
import argparse import sys
sys.path.append('D:\workspace\meetslut')
from meetslut.processor.caitlin import caitlin_download from meetslut.processor.caitlin import caitlin_download
from meetslut.processor.zipai import zipai_download from meetslut.processor.zipai import zipai_download
from meetslut.processor.motherless import motherless_download from meetslut.processor.motherless import motherless_download
...@@ -17,6 +17,17 @@ def caitlin(args): ...@@ -17,6 +17,17 @@ def caitlin(args):
def motherless(args): def motherless(args):
motherless_download(args.url, args.output) motherless_download(args.url, args.output)
def setup_logger():
logger = logging.getLogger()
logger.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s [%(levelname)-5s] [%(filename)s:%(lineno)d] %(message)s', datefmt='%d/%m/%Y %H:%M:%S')
console = logging.StreamHandler()
console.setFormatter(formatter)
console.setLevel(logging.DEBUG)
logger.addHandler(console)
def main(): def main():
parser = argparse.ArgumentParser(description="A fancy downloader for slut.") parser = argparse.ArgumentParser(description="A fancy downloader for slut.")
...@@ -53,7 +64,9 @@ def main(): ...@@ -53,7 +64,9 @@ def main():
args = parser.parse_args() args = parser.parse_args()
args.func(args) # args.func(args)
if __name__ == "__main__": if __name__ == "__main__":
main() setup_logger()
\ No newline at end of file logging.info("🚀 Start...")
# main()
\ No newline at end of file
# num of threads for downloading resources
NUM_THREADS = 4 NUM_THREADS = 4
# requests max retry
RETRY = 3 RETRY = 3
# header
HEADERS = { HEADERS = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36" "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36"
} }
# proxy
PROXIES = {
'http': 'socks5h://127.0.0.1:2801',
'https': 'socks5h://127.0.0.1:2801'
}
ROOT_ZIPAI = "https://99zipai.com" ROOT_ZIPAI = "https://99zipai.com"
\ No newline at end of file
import os, re, json
import requests
import sys
sys.path.append('D:\workspace\meetslut')
from bs4 import BeautifulSoup
from bs4.element import Tag, NavigableString
from meetslut.config import HEADERS, PROXIES
def parse(url):
r = requests.get(url, headers=HEADERS, proxies=PROXIES, timeout=5)
assert r.status_code == 200
r.encoding = r.apparent_encoding
soup = BeautifulSoup(r.text, "html.parser")
album = soup.find("div", attrs={"id": "album"})
title = album.div.h1.text.strip()
wrapper = album.findAll("a", attrs={"class": "gallery-link"})
res = {
"title": title,
"data": [{'name': a.img.attrs['alt'], 'url': a.img.attrs['data-lazy-src']} for a in wrapper]
}
return res
if __name__ == '__main__':
url = "https://www.pictoa.com/albums/white-women-getting-cream-pies-from-bbc-588816-p5.html"
print(parse(url))
\ No newline at end of file
...@@ -48,15 +48,6 @@ def worklist(uid): ...@@ -48,15 +48,6 @@ def worklist(uid):
a = li.a a = li.a
yield a.text, a.get("href") yield a.text, a.get("href")
def main(author):
data = []
for title, href in worklist(author):
if input(f"Download {title}({ROOT+href})[y/n]?: ")[0].lower() == "y":
article(href)
data.append([href.split("/")[-1].split(".")[0], title])
print(data[::-1])
def zipai_download(url, folder): def zipai_download(url, folder):
if url.startswith("https://www.99zipai.com/selfies"): if url.startswith("https://www.99zipai.com/selfies"):
title, images = article(url) title, images = article(url)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册