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.2.tar.gz (12.3 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.2-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: toolboxbyhanxu-1.0.2.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for toolboxbyhanxu-1.0.2.tar.gz
Algorithm Hash digest
SHA256 8c3e4627324feb29db4e29e4a50320822ced849eaf8e9c82309edfbc073d8c72
MD5 9e6976bd4a84db6a86a8ddedb77bbc24
BLAKE2b-256 e7c88328e749658450467b7b13981a4196cff27db54c70f4a675b230efd3dda8

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ToolBoxByHanXu-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 16740ede099bbeb4abf8b81a54ff6f38163bfa76662a98f578a7edcc3f069efa
MD5 549dc79a8cb9ddbd58b2192702af42bc
BLAKE2b-256 8e3e24034988fc7380798b5308a68ff25c1b7ea34c492ea16398ab7096ec7c4b

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