Skip to main content

This is a repo of some small tools created by python.

Project description

Brief

This is a repo of some smallTools created by python.

module 1:image_spider

  • This tool allow you to crawl images from 3 website, which are Pixiv,Bing and Baidu.

Module:pixiv

  • Make sure that your internet can visit the foreign websites.
  • The module has two ways to crawl images:Rank and keyword.

Easy use

import ToolBoxByHanXu.image_spider.pixiv as pixiv
if __name__ == '__main__':
    example=pixiv.pixiv_spider()
    example()

search by Rank

  • Looking at the following example:
{'1': 'Rank', '2': 'Keyword'}
Type in the target you want to search.
1
{'1': 'Simple:Recommended and Fast because the downloaded images are vague.You can view the simple image and select what you love', '2': 'Specific:Not Recommended and Slow because the downloaded images are clear'}
Type in the requirement of download-mode.
1
type in the path where you want to reserve the images:
rank20230424
Type in the number of images you want:
5
{'1': 'daily', '2': 'weekly', '3': 'monthly', '4': 'rookie', '5': 'daily_ai', '6': 'male', '7': 'female'}
type in the searchMode you want
1
Type in the date you want to search.Follow the format like this:20230423
20230424

search by keyword

{'1': 'Rank', '2': 'Keyword'}
Type in the target you want to search.
2
{'1': 'Simple:Recommended and Fast because the downloaded images are vague.You can view the simple image and select what you love', '2': 'Specific:Not Recommended and Slow because the downloaded images are clear'}
Type in the requirement of download-mode.
1
type in the path where you want to reserve the images:
秋山澪图片
Type in the number of images you want:
5
{'1': '500', '2': '1000', '3': '5000', '4': '10000'}
Type in the requirement of heat.Larger the number is,Less the results are.
2
type in the keywords used to search in pixiv:
秋山澪

Module:bing

  • Use the following code to run the module.
import ToolBoxByHanXu.image_spider.bing as bing

if __name__ == '__main__':
    example=bing.Spider_bing_image()
    example()
type in the path where you want to reserve the images:秋山澪
type in the keywords used to search in bing:秋山澪
Type in the number of pages you want.Each page has almost 30 images:1

Module:baidu

  • The package can crawl the images at baidu based on the keyword offered by you.
  • use the following code to use the package
import ToolBoxByHanXu.image_spider.baidu as baidu

if __name__ == '__main__':
    example = baidu.Spider_baidu_image()
    example()
type in the path where you want to reserve the images:秋山澪
type in the keywords used to search in Baidu:秋山澪
Type in the number of pages you want.Each page has 30 images:1

module 2:normalize_md

  • Usually, when we write the md file, the images in the md file are bundled with the internet. If you want to view the images offline, you should download the images at advanced and modify the image-urls in the md file, which is awful and takes much time! This tool allow you to download the internal images in the md file automatically so that you could view the md file without the internet anymore!
  • The algorithm is in-place!You'd better copy the md dir in advance.
import ToolBoxByHanXu.normalize_md as normal

if __name__ == '__main__':
    # replace the directory you want to rename
    target_directory = r"D:\Desktop\demo"
    normal.normalizer(current_dir=target_directory)()

result:

  • before:

在这里插入图片描述

在这里插入图片描述

  • after:

在这里插入图片描述

在这里插入图片描述

module 3:rename_files

  • This tool could rename all the files in a directory decided by you. You have 2 choices to rename them.

rename by order

  • If you don't mind the filename extension, you could rename all of them at one time.Given New name and order key, the code will add the order automatically.
import ToolBoxByHanXu.rename_files as rename

if __name__ == '__main__':
    # replace the directory you want to rename
    example=rename.renamer(r"D:\Desktop\C & C++")
    example(new_name="demo",order_key=lambda x: int(x[ x.rfind(".")-1 : x.rfind(".")+1] ) )

rename by filename extension

  • For example, if you want to rename all the images, you may type in jpg or png as followed.
import ToolBoxByHanXu.rename_files as rename

if __name__ == '__main__':
    # replace the directory you want to rename
    example=rename.renamer(r"D:\Desktop\C & C++")
    example(new_name="demo",target_type="jpg")

result:

在这里插入图片描述

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toolboxbyhanxu-1.0.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ToolBoxByHanXu-1.0.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file toolboxbyhanxu-1.0.1.tar.gz.

File metadata

  • Download URL: toolboxbyhanxu-1.0.1.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for toolboxbyhanxu-1.0.1.tar.gz
Algorithm Hash digest
SHA256 8b754c38af4748a23eaed593fef06a4c4fe0209be8d9aea0f97439268b87025f
MD5 b532cc5cb6e41c6df3f23b252aefdf0a
BLAKE2b-256 fe39fd2743f1eada64cc22866248bba513ab16e4ea2805f5a77b53c14e7745c1

See more details on using hashes here.

File details

Details for the file ToolBoxByHanXu-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ToolBoxByHanXu-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ToolBoxByHanXu-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e144afef85c0a832cd122c9ce1a77cde48365c1112e0242f0f39c812cff63f48
MD5 7c12b2b9b4730d5c2d9bcbcd8a99bf3e
BLAKE2b-256 3996982ff688c2bf4fea20205d2391ccbb527dbef47e447e459e0f2dff682705

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page