From fe9ac759f9a411e476ca6a711c73ff9151f8115c Mon Sep 17 00:00:00 2001 From: crj1998 Date: Sat, 5 Nov 2022 14:19:13 +0800 Subject: [PATCH] add pictoa --- README.md | 38 ++++++++++++++++++++++++++---------- meetslut/cli.py | 23 +++++++++++++++++----- meetslut/config.py | 10 ++++++++-- meetslut/processor/pictoa.py | 27 +++++++++++++++++++++++++ meetslut/processor/zipai.py | 9 --------- 5 files changed, 81 insertions(+), 26 deletions(-) create mode 100644 meetslut/processor/pictoa.py diff --git a/README.md b/README.md index b20e9d2..1bbfb94 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # 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 git clone @@ -9,8 +11,7 @@ cd meetslut 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 ``` @@ -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 ``` -### 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/) -- [zipai](https://99zipai.com/) -- [Imagefap]() -- [motherless]() +## πŸ‘‹ Acknowledgement +- https://jinglong233.gitee.io/markdownIcon/ +- Tutorial from πŸ“¦ [Converting Python Script Into a Command-line Tool](https://betterprogramming.pub/build-your-python-script-into-a-command-line-tool-f0817e7cebda) -## License \ No newline at end of file +## For Developers +parser: input a url, output a dict {"url": ..., "name": ...} \ No newline at end of file diff --git a/meetslut/cli.py b/meetslut/cli.py index 03023fa..03467c0 100644 --- a/meetslut/cli.py +++ b/meetslut/cli.py @@ -1,9 +1,9 @@ """ The Command Line Interface (CLI) for the downloader """ -import os -import argparse - +import os, argparse, logging +import sys +sys.path.append('D:\workspace\meetslut') from meetslut.processor.caitlin import caitlin_download from meetslut.processor.zipai import zipai_download from meetslut.processor.motherless import motherless_download @@ -17,6 +17,17 @@ def caitlin(args): def motherless(args): 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(): parser = argparse.ArgumentParser(description="A fancy downloader for slut.") @@ -53,7 +64,9 @@ def main(): args = parser.parse_args() - args.func(args) + # args.func(args) if __name__ == "__main__": - main() \ No newline at end of file + setup_logger() + logging.info("πŸš€ Start...") + # main() \ No newline at end of file diff --git a/meetslut/config.py b/meetslut/config.py index 28de365..8f129d2 100644 --- a/meetslut/config.py +++ b/meetslut/config.py @@ -1,9 +1,15 @@ +# num of threads for downloading resources NUM_THREADS = 4 +# requests max retry RETRY = 3 - +# header 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" } - +# proxy +PROXIES = { + 'http': 'socks5h://127.0.0.1:2801', + 'https': 'socks5h://127.0.0.1:2801' +} ROOT_ZIPAI = "https://99zipai.com" \ No newline at end of file diff --git a/meetslut/processor/pictoa.py b/meetslut/processor/pictoa.py new file mode 100644 index 0000000..257ecf2 --- /dev/null +++ b/meetslut/processor/pictoa.py @@ -0,0 +1,27 @@ +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 diff --git a/meetslut/processor/zipai.py b/meetslut/processor/zipai.py index e65b17f..f9bdf00 100644 --- a/meetslut/processor/zipai.py +++ b/meetslut/processor/zipai.py @@ -48,15 +48,6 @@ def worklist(uid): a = li.a 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): if url.startswith("https://www.99zipai.com/selfies"): title, images = article(url) -- GitLab