Skip to content

ciring/weiboPicDownloader

 
 

Repository files navigation

weiboPicDownloader

(not real) weibo user album batch download tool (CLI)

build user album by picking all photos from original weibos in user's post feed

for more weibo free login APIs, turn to wiki

中文 README

weibo_follow README

引用https://github.com/fireattack/weiboPicDownloader

https://github.com/dataabc/weibo-follow

修改weiboPicDownloader.py read_from_file函数

修改1.方便直接使用weibo-follow爬取的user_id_list.txt文件

def read_from_file(path):
    try:
        with open(path, 'r', encoding='gb18030', errors='ignore') as f:
            empty = []
            str = [line.strip() for line in f]
            for uncode in str:
                empty.append(uncode[0:10])
            return empty
    except Exception as e:
        quit(str(e))

修改2.记录当前步骤到文件

在main函数里for number, user in enumerate(users, 1): 这个循环的位置后,增加

        file_log = open('log.txt', 'w')
        file_log.write('{}/{}'.format(number, len(users)) + '\n')
        file_log.close()                     #记录下载了的账号在文件中的位置,方便异常定位位置

References

yAnXImIN/weiboPicDownloader

ningshu/weiboPicDownloader

Overview

Dependencies

$ pip install requests
$ pip install colorama # only windows version under 10.0.14393 required
$ pip install futures # only python2 environment required

Usage

$ python .\weiboPicDownloader.py -h
usage: weiboPicDownloader [-h] (-u user [user ...] | -f file [file ...])
                          [-d directory] [-s size] [-r retry] [-i interval]
                          [-c cookie] [-b boundary] [-n name] [-v] [-o]

optional arguments:
  -h, --help          show this help message and exit
  -u user [user ...]  specify nickname or id of weibo users
  -f file [file ...]  import list of users from files
  -d directory        set picture saving path
  -s size             set size of thread pool
  -r retry            set maximum number of retries
  -i interval         set interval for feed requests
  -c cookie           set cookie if needed
  -b boundary         focus on weibos in the id range
  -n name             customize naming format
  -v                  download videos together
  -o                  overwrite existing files

Required argument (choose one)

  • -u user ... users (nickname or id)
  • -f file ... user list files (nickname or id, separated by linefeed in the file)

Optional arguments

  • -d directory media saving path (default value: ./weiboPic)
  • -s size thread pool size (default value: 20)
  • -r retry max retries (default value: 2)
  • -i interval request interval (default value: 1, unit: second)
  • -c cookie login credential (only need the value of a certain key named SUB)
  • -b boundary mid/bid/date range of weibos (format: id:id between, :id before, id: after, id certain, : all)
  • -n name naming template (identifier: url, index, type, mid, bid, date, text, name, like "f-Strings" syntax)
  • -v download miaopai videos at the same time
  • -o overwrite existing files (skipping if exists for default)

✳How to get the value of SUB from browser (Chrome for example)

  1. jump to https://m.weibo.cn and log in
  2. inspect > Application > Cookies > https://m.weibo.cn
  3. double click the SUB line and copy its value
  4. paste it into terminal and run like -c <value>

About

Download weibo images without logging-in

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%